How to check the value of List field in IF condition for getting related group approvals

Suzy
Tera Contributor

I have Functional area List field on form, FTM and DTS,ODG as values

if i select one value in Functional Area, approval should go for the related group.

for eg. If i select FTM, the approval should go to FTM Group approval only.

I have tried Switch but it is requesting approvals from all existed groups so now i am trying with IF Condition like as shown in the below image but it's not working. Please help me how to write the condition if in case need to write any script i have written below script its throwing error

 

answer = ifScript();

function ifScript() {
if (current.u_functional_area.indexOf('FTM')>-1) {
return 'yes';
}
return 'no';
}

find_real_file.png

 

 

Related Images:

find_real_file.png

 

 

find_real_file.png

1 ACCEPTED SOLUTION

Let's make double sure this array doesn't give trouble:

Use this(Added another toString() in the answer push):

var approvers = current.fieldName.toString();//Replace your field name
var answer = [];

if (approvers) {
    var approversArr = approvers.split(',');

    for (var i = 0; i < approversArr.length; i++) {
        answer.push(approversArr[i].toString());
    }
}

View solution in original post

29 REPLIES 29

Anirudh,

There are no choices over there.

find_real_file.png

Hmmm.... Let's check the logs.

Add the code like:

var approvers = current.fieldName.toString();//Replace your field name
gs.info('approvers  - ' + approvers );

 

And check in log table for message starts with approvers.

What do you get...?

This should work(pakka!):

var approvers = current.fieldName.toString();//Replace your field name
var answer = [];

if (approvers) {
    var approversArr = approvers.split(',');

    for (var i = 0; i < approversArr.length; i++) {
		if(approversArr[i].toString() == 'FTM')
			answer.push('put FTM sys id here');
		else if(approversArr[i].toString() == 'DTS')
			answer.push('put DTS sys id here');
    }
}

Suzy, could you give the name of the table in which Functional Area is stored... and also the name of the field where the names are stored....

For example The text FTM might be stored in Name(u_name) field... like that

 

 

Hi Anirudh,

 

Thanks a lot for the answer :>:>

 

Adding below conditions(Wait Condition for functional area and group approval with code)  solved the issue. Now its running fine...  🙂

 

Thanks!! 

find_real_file.png