- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-28-2023 08:41 AM
Hi all,
I'm having an issue within my workflow. As you can see in my form below, the user is forced to select who the request is for (highlighted blue - value is on_behalf), and the potential approver for the request (highlighted green - value is select_partner).
In my workflow I want to workout if the selected partner needs to approve the request or not. This is done simply by checking if the requester's 'Salesforce Firm Association'..
.. is contained within the Partner's 'Key Individual of Partners' field. Both fields are on their sys_user records.
The script I have so far in the IF statement is failing but it is as below:
var salesforce_association = current.on_behalf.u_salesforce_firm_association.toString();
if(current.variables.select_partner.u_partnership_number.toString().indexOf(salesforce_association) > -1 ){
answer = 'yes';
}else{
answer = 'no';
}
Any advice on where I'm going wrong here would be greatly appreciated as the above script is patched together from a number of similar questions. Thank you!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-28-2023 02:32 PM
I managed to get it working - I was missing the answer = ifScript(); and then the function ifScript(){} part of the code. Works perfectly fine now.
answer = ifScript();
function ifScript(){
if(current.variables.partners_p_code.toString().indexOf(current.variables.salesforce_fa.toString()) > -1){
return 'yes';
}else{
return 'no';
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-28-2023 08:53 AM
Hi @Liam Rhodes
Is your Salesforce firm association field on the catalog item, then in the first line shouldn't you go with
var salesforce_association = current.variables.behalf_of.......
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-28-2023 11:56 AM
Thanks Aman - good spot. I've updated that now and rather than failing I'm getting a 'yes' answer even for results where it should definitely be a 'no'. Any ideas?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-28-2023 09:17 AM
Hi Liam,
I had a look on your previous question and seems like the name of your field is u_key_individual_of_partners instead of u_partnership_number.
You can try with correct field name like below.
var salesforce_association = current.on_behalf.u_salesforce_firm_association.toString();
if(current.variables.select_partner.u_key_individual_of_partners.toString().indexOf(salesforce_association) > -1 ){
answer = 'yes';
}else{
answer = 'no';
}
Hopefully, this will resolve your query.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-28-2023 11:57 AM
Apologies, I screenshot the wrong field on the user record. The u_partnership_number is the correct field I want to compare against.