How to Apply If Else Condition in Reference Qualifier

Community Alums
Not applicable

Hello Everyone,

 

1) I have two variables on the form -

i) request type (request_type) - choice field - internal, external

ii) members (members) - list collector - sys_user table having test@gmail.com (internal user), test.ext@gmail.com (external user with "ext" mentioned in it)

 

I am having below requirement:

Now If I select 'request type' as 'internal' then only internal users should visible in the 'members' field and If I select 'request type' as 'external' then users having email ID containing 'ext' in it should be visible.

 

trying to achieve through reference qualifier of 'members' field.

 

Thanks,

Tejas

 

 

2 REPLIES 2

SN_Learn
Kilo Patron
Kilo Patron

Hi @Community Alums ,

 

Please try the below:

javascript: var query; if (current.variables.request_type == "internal") query = 'emailNOT LIKEext'+(current.cat_item.sys_id||current.request_item.cat_item.sys_id);  else query = 'emailLIKEext'+(current.cat_item.sys_id||current.request_item.cat_item.sys_id); query;

 

SN_Learn_0-1722325833988.png

 

 

----------------------------------------------------------------
Mark this as Helpful / Accept the Solution if this helps.

Amit Verma
Kilo Patron
Kilo Patron

Hi @Community Alums 

 

As a best practice, you should move your if-else logic to a Script Include and call it from the reference qualifier. You should not put if-else condition in a Reference Qualifier. You can refer below posts for reference :

https://www.servicenow.com/community/developer-forum/how-to-use-if-else-statement-in-reference-qualifier/m-p/2080184

https://www.servicenow.com/community/developer-forum/create-reference-qualifier-filter-with-if-else-statement/td-p/2484369

 

Thanks and Regards

Amit Verma


Please mark this response as correct and helpful if it assisted you with your question.