Workflow 'IF' activity to check if value in one users field matches in another users field.

Liam Rhodes
Kilo Guru

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).

LiamRhodes_0-1701189377582.png

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'..

LiamRhodes_1-1701189515079.png

 

.. is contained within the Partner's 'Key Individual of Partners' field. Both fields are on their sys_user records.

LiamRhodes_2-1701189577527.png

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!

 

 

1 ACCEPTED SOLUTION

Liam Rhodes
Kilo Guru

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';

	}
	
}

 

View solution in original post

5 REPLIES 5

Liam Rhodes
Kilo Guru

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';

	}
	
}