- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2018 09:09 AM
Hello - I am have a "user approval" activity in my catalog item's workflow and I want to use conditions to state who the approval should come from. I can script the conditions, but I don't know how to script the approval parts. It should look something like this:
If condition 1,
approval comes from person A
Else
approval comes from person B
The "approval comes from" part is what I don't know how to script. I don't know if I've explained this properly, so please let me know if additional information is needed. Thank you.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2018 11:57 AM
Hello John,
Use below code:
answer = [];
var mgr;
//Set manager to requested for if it's not empty, else set manager to requested by
if(!current.variables.u_requested_for) {
// check for the u_requested_for variable
//use either u_requested_for or requested_for
mgr = current.u_requested_for.manager;
}
else {
mgr = current.u_requested_by.manager;
}
answer.push(mgr);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2018 02:36 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2018 11:15 AM
Hi Vidisha, thanks for getting back to me. Apologies for the late response as I haven't had to work on this issue in a while. But now it's resurfaced. I tried your suggestion, albeit not correctly. The scenario is that our request forms have 2 requester fields: "requested by" and "requested for". The requested by is always populated, the requested for is optional. In the case of approvals, if the requested for is populated the approval should come from that person's manager. If the requested for field is blank, the approval should come from the requested by's manager. The approval script I wrote is always approving, so clearly something is wrong. Here it is:
answer = [];
var mgr;
//Set manager to requested for if it's not empty, else set manager to requested by
if(!!current.variables.requested_for) {
mgr = current.u_requested_for.manager;
}
else {
mgr = current.u_requested_by.manager;
}
answer.push('mgr');
Any suggestions would be appreciated!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2018 11:25 AM
Hello John,
Replace answer.push('mgr'); with answer.push(mgr); in your script.
Remove quotes from mgr.
Thanks
Vidisha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2018 11:33 AM
Thank you so much!!! Ultimately such a small thing, but I'm new to coding and I find myself doing things like this often. I really appreciate you helping me to get this resolved.