- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2017 06:27 PM
I need to have the approval group in my workflow be dynamic based on what the users selects from a request form field. Here are the details. My request form has a lookup select box called Location (location) that is referring a table holding all my locations. I am using a BR to copy the selected location to a table column called Shuttle Location (shuttle_location). I have a workflow associated with this request form with a group approval and this approval has to vary depending on the location is selected. Each location has its own approval group. And there are dozens of locations, thus the need to do this dynamically. I could build this in the workflow with a switch flowing to all the different approvals, but that would be ugly and not very maintainable since locations will change. I've tried using the below script to make this approval group dynamic, but I keep getting an error that "shuttle_location" is not defined. Is this switch script the correct way to do this? Should it be referencing the form variable location rather than the table column shuttle_location that I am copy location to?
var answer = [];
switch(shuttle_location){
case 'nebraska city':
- answer.push('Shuttle - Nebraska City');
break;
case 'new rockford':
- answer.push('Shuttle - New Rockford');
break;
case 'jamestown':
- answer.push('Shuttle - Jamestown');
break;
case 'amarillo':
- answer.push('Shuttle - Amarillo');
break;
default:
- answer.push('Default Approvers');
}
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2017 10:28 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2017 08:26 PM
can you please put log in your script.
gs.log(current.variables.shuttle_location.toString()); check what are you getting here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2017 08:37 PM
Harshvardhan
Do I put the gs.log in place of the script or in a certain spot of the script? Where do I view the output?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2017 08:40 PM
var answer = [];
gs.log(current.variables.shuttle_location.toString());
switch(current.variables.shuttle_location.toString()){
case 'nebraska city':
- answer.push('Shuttle - Nebraska City');
break;case 'new rockford':
- answer.push('Shuttle - New Rockford');
break;case 'jamestown':
- answer.push('Shuttle - Jamestown');
break;case 'amarillo':
- answer.push('Shuttle - Amarillo');
break;default:
- answer.push('Default Approvers');
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2017 08:54 PM
I did this, but not sure where to view the output. I looked in System Log > All, but not seeing anything that looks relevant to this. Should I be looking somewhere else?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2017 08:59 PM
sorry my bad
Updated Script:
var answer = [];
gs.log('what is in variable :'+current.variables.shuttle_location.toString());
switch(current.variables.shuttle_location.toString()){
case 'nebraska city':
answer.push('Shuttle - Nebraska City');
break;
case 'new rockford':
answer.push('Shuttle - New Rockford');
break;
case 'jamestown':
answer.push('Shuttle - Jamestown');
break;
case 'amarillo':
answer.push('Shuttle - Amarillo');
break;
default:
answer.push('Default Approvers');
}
search in logs table System Log > All and enter what is in variable in message column in list