- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2017 12:04 PM
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.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2017 10:20 PM
Hi Jorge,
Please add a run script block like below in Workflow
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2017 01:17 PM
Hi Jorge,
You can use like below script in your onLoad Client Script modify the field and service provider names properly:
function onLoad() {
reqNum = g_form.getReference('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'){
g_form.setValue('u_service_provider', 'ServiceProvider1');
}
else g_form.setValue('u_service_provider', 'ServiceProvider2');
}
Thanks,
Arindam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2017 10:21 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2017 12:17 PM
Please share your script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2017 12:56 PM
The variable provider is hidden in the form(single text), and it should be autopopulated depending the end of the request number
function onLoad(){
reqNum = g_form.getReference('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'){
g_form.setValue('provider', 'Movil Ride'); // provider is the variable that should get the string value 'Movil Ride'
}
else {
g_form.setValue('provider', 'Movil Ex');
}
}
Thanks