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

shloke04
Kilo Patron

Hi Narmi,



As mentioned by Pradeep, you can use the if Condition as mentioned above, but with few changes as mentioned below:



Script:



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


  {


  current.update();


  action.setRedirectURL(current);       //This will redirect to the current form after submission


}


else


  {


  current.update();


  var url = 'Table_Name_list.do?sysparm_query=sys_updated_byDYNAMIC'+ gs.getUserName()+'^ORDERBYDESCsys_updated_on';


  action.setRedirectURL(url);     //This will redirect to the List view



}



In the above Script in line Number 9 where we are forming the URL, simply Replace your Table Name in place of "Table_Name" and it will also show you the latest record being displayed at the top.



find_real_file.png




Hope this helps.Mark the answer as correct/helpful based on impact.



Regards,


Shloke


Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke