Using If condition in UI Action, If True Perform some action and If False Perform another action

farci
Mega Expert

Using If condition in UI Action, If True Perform some action and If False Perform another action:

I have a UI Action button wherein I want to include if condition within the script.

For Example: IF my logged in user is the same as 'assign to' in the form then it should save record and redirect to the same record. IF NOT then it should Save the record and redirect to the list view of that table.

Appreciate your suggestion and help.

Regards,

Narmi

1 ACCEPTED SOLUTION

farci
Mega Expert

Below is the script I used it works fine



if(current.ass_si==gs.getUserID()){



  action.setRedirectURL(current);



}


else{



  action.setRedirectURL('table_name_list');


}


View solution in original post

5 REPLIES 5

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hello Narmi,



Code wil be


if(gs.getUserID() = current.assigned_to)


  {


  current.update();


  }


else


  {


  current.update();


  action.setRedirectURL(current);


  }



https://www.servicenowguru.com/system-ui/ui-actions-system-ui/client-server-code-ui-action/


Thank You, Pradeep


farci
Mega Expert

Below is the script I used it works fine



if(current.ass_si==gs.getUserID()){



  action.setRedirectURL(current);



}


else{



  action.setRedirectURL('table_name_list');


}


Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Thank you Narmi for the update. I'm Glad you got it resolved. I see i have got condition reversed in my code.