Vlocity, salesforce amend the existing Omniscript Controls – User friendly Tech help

Prerequisite:- Need access to vlocity omniscript (OS) templates, we need vlcTel.txt code base, so we can override the existing omniscript telephone control behavior

n

Before > SFDC has phone value as 8 digits say, OS won’t show its value on the UI by default as ng-pattern won’t be valid thus it’s not pre-populated with 8 digits phone.

n

After > A workaround, in our case we still need to show the phone, as 8 digits but indicate an error to users on the UI, so that they can correct this value here instead of going to Salesforce

n

Step1:- Fetch the vlcText and create new vlocity template

n

nn    nn        nn        nn            nn                nnn                {{::control.propSetMap.label}}n                    n                    n                nn                n                 i nnn            nn            nn        nn    nnn

n

Step2:- Override the existing behavior of control in OS by referring to the newly created template in “HTML Template Mapping

n

    n

  • OS > Designer >Script Configuration > HTML Template Mapping
  • n

n

Step3:- Customize the vlcText to add your own custom logic, like we added the custom logic in controller, which overrides the existing OS behavior

n

HTML

n

n    nn        nn        nn            nn                nnn                {{::control.propSetMap.label}}n                    n                    n                nn                n                 i nnn            nn            nn        nn    nnn

n

JS (Controller)

n

vlocity.cardframework.registerModule.controller('textFieldController', ['$scope', function($scope) {nn $scope.getClass = control => {n     const value = control.responsen        //regex match for phone and faxn        if( (value && value.match(/\d/g) && value.match(/\d/g).length === 10) n            || n            ( control.name === 'Fax' && isFaxValueExists(value)) //fax is not requiredn         )n        {n            return 'isValid'n        }nn      return 'notValid'n    }nnconst isFaxValueExists = value => value === '' || value === null  nn}]);
Was this article helpful?
YesNo

Similar Posts