How to add If/else statemet in reference qualifier

Kaustubh k
Tera Contributor

Hi All,

 

We have a requirement where I need to add two functions of a script include with if else condition.

If variable is Add Members then it should be script include and the below function

ClientUtils().isManagerOfGroup(); and variable is Remove Member then it should be other function 

ClientUtils().isOwnerOfGroup();

 

Thanks in Advance

4 REPLIES 4

anubhavkapoor76
ServiceNow Employee
ServiceNow Employee

@Kaustubh k - Which variable are you referring to - catalog variable? Please describe your question in detail (preferable with screenshots)

 

I would call just one SI function with one parameter and let the parent function of SI decide which other SI function to call based on the value of the passing parameter.

 

 

Hi Anubhav,

 

Yes I am referring to a variable of a catalog item 'Group Name'.

 

If they select Add Members or Remove Members ,then it should only populate the groups whom I am manager of in the Group Name,for which I have a script include and an function- ClientUtils().isManagerOfGroup(); and for rest I want to populate the groups for which I am owner -ClientUtils().isOwnerOfGroup();

 

Kaustubhk_0-1730186593180.png

 

Thanks

Suraj Sharma
Giga Guru

Add this is is you refQual:- new javascript : if="current.variable=='Remove Managers'||current.variable=='add memeber'"?ClientUtils().isManagerOfGroup() : ClientUtils().isOwnerOfGroup()

if any query reach out to me...

if this resolve your query please Mark helpfull this answer..!!!!

Eshwar Reddy
Kilo Sage

Hi @Kaustubh k 

Create a new function in the ClientUtils() script include and pass the action parameter to the manageGroup function.

Example script
manageGroup: function(action)

{

if (action === 'Add Members')

{

return this.addMembers();

} else if (action === 'Remove Members')

{

return this.removeMembers();

}

},

 

Please mark this response as Correct and Helpful if it helps you can mark more that one reply as accepted solution


Thanks
Eshwar