How to get in a variable the request number and use it in a script

jorgetop
Kilo Contributor

Hi there,

I ´m trying to get the request number generated and use it in a onLoad script, and if the request number ends with pair number,

a field called "Service Provider(single text)" that I've created will be auto populated with a string value(Name of the provider) or if the condition

is false(request number ends with odd number) the field "Service provider" will be auto-populated with another provider name.

This functionality is because the user needs that the service provider appears in the report, and there are two providers, hence the request ending

with odd number triggers the emails to one provider and the ones ending with a pair number go to the other provider.

Thanks in advance, appreciate any help.

1 ACCEPTED SOLUTION

Hi Jorge,



Please add a run script block like below in Workflow


find_real_file.png



Inside Run script block use the below script:



var reqNum = current.request.number;


var array = reqNum.toLowerCase().split('');


arrLength = array.length;


var str = reqNum.substr(array.length-1, array.length);


                      if (str=='0'||str=='2'||str == '4'||str == '6'||str == '8'){  


current.variables.provider = 'Movil Ride';


                      }  


else current.variables.provider = 'Movil Ex';




Thanks,


Arindam


View solution in original post

6 REPLIES 6

Hi Jorge,



Please add a run script block like below in Workflow


find_real_file.png



Inside Run script block use the below script:



var reqNum = current.request.number;


var array = reqNum.toLowerCase().split('');


arrLength = array.length;


var str = reqNum.substr(array.length-1, array.length);


                      if (str=='0'||str=='2'||str == '4'||str == '6'||str == '8'){  


current.variables.provider = 'Movil Ride';


                      }  


else current.variables.provider = 'Movil Ex';




Thanks,


Arindam


Hi Arindam,




Awesome, this time it works perfectly, thanks for your help and support




Best Regards



Jorge Glez