- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-07-2017 10:57 PM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-07-2017 11:21 PM
Below is the script I used it works fine
if(current.ass_si==gs.getUserID()){
action.setRedirectURL(current);
}
else{
action.setRedirectURL('table_name_list');
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-07-2017 11:23 PM
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.
Hope this helps.Mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke