Choice list options should be visible as per other three choice field selection in record producer

ServiceNow10sun
Giga Guru

Hi All , 

 

I have requirement in a record producer there 4 choice variables based on the 3 choice variables selection the choice list should populate in the 4th  choice list. 

 

Example there are Field 1 : 'Name'  which has choices ( Anita , Nithya , Sunita, Swetha )

Field 2 :  'Address' which has choices ( Pune , Bangalore , Chennai , Mumbai )

Field 3 : 'State ' which has choices ( Closed , Open , Onhold , Incomplete)

Field 4 : 'Software' which has choices ( Azure , Microsoft , Google, Jira ) 

 

NameAddressStateSoftware
AnitaPuneClosedAzure
NithyaBangaloreOpenMircosoft
SunitaChennaiOnholdGoogle
SwethaMumbaiIncompleteJira

 

So when in name field ' Sunita' , in address field its 'Bangalore , state field is 'Onhold' then in 'Software' field  choices Microsoft and Google should show as choice and other choices Azure and Jira should be hidden. 

 

Similarly as per the other choices same Software field choices should change. 

 

i have tried onChange client script  of Name field : 

 

Var aa = g_form.getValue(' Name');

Var bb= g_form.getValue(' Address');

Var cc= g_form.getValue(' State ');

Var dd= g_form.getValue(' Software');

 

if (aa=='Sunita' && bb=='Bangalore' && cc=='Onhold')

{

g_form.removeOption('software' , 'azure' , 'Azure');

g_form.removeOption('software' , 'jira ' , 'Jira ');

g_form.addOption('software', 'microsoft ', 'Microsoft');

g_form.addOption('software', 'google', 'Google ');

 

}

 

@Ankur Bawiskar @Saurav11 @Ratnakar7 

 

 

10 REPLIES 10

Community Alums
Not applicable

Hi @ServiceNow10sun ,

To which table you've added this record producer ?

Prince Arora
Tera Sage
Tera Sage

@ServiceNow10sun 

1) Please confirm that you want only those cases which is mentioned in below table.
2) The user will fill out all three fields on the form, namely Name, Address, and State, and we will only need to write logic for the software? is my understanding correct?

NameAddressStateSoftware
AnitaPuneClosedAzure
NithyaBangaloreOpenMircosoft
SunitaChennaiOnholdGoogle
SwethaMumbaiIncompleteJira


If my answer solved your issue, please mark my answer as Correct & 👍Helpful based on the Impact.

Hi , 

User will select the choice from the fields 'Name' , 'Address'  and State and selected choices only should be visible in the field ' Software' . 

@ServiceNow10sun ,

 

You can try this way:

Var bb= g_form.getValue(' Address');

Var cc= g_form.getValue(' State ');

Var dd= g_form.getValue(' Software');

 

g_form.clearOptions("software");// Add this to clear the options first and then you can just add the conditional options as describe below

 

if (newValue=='Sunita' && bb=='Bangalore' && cc=='Onhold'){

g_form.addOption('software', 'microsoft ', 'Microsoft');

g_form.addOption('software', 'google', 'Google ');

}

else if( newValue == 'Anita' && bb == 'Pune' && cc == 'Closed'){

g_form.addOption('software', 'microsoft ', 'Microsoft');

g_form.addOption('software', 'google', 'Google ');

}

else if( newValue == 'Nithya' && bb == 'Bangalore' && cc == 'Open'){

g_form.addOption('software', 'microsoft ', 'Microsoft');

g_form.addOption('software', 'google', 'Google ');

}
and so on for the further conditions..

Please add the options based on your test case, as I can only explain how we can accomplish this because I don't have the entire use case.

If my answer solved your issue, please mark my answer as Correct & 👍Helpful based on the Impact.