
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2022 07:02 AM
Hello,
I have an UI action that is applied on both list and form. The button contains a script include and I have some calculations in it.
What I want to do is to redirect to current form when the UI action is clicked from form and of course, redirect to list when the UI action is clicked from the list.
I was thinking to add in my script something like:
if(clickedfromlist){ //no clue how to "call this"
var url=current.getTableName()+'_list.do';
action.setRedirectURL(url);
}else{
action.setRedirectURL(current);
}
If there any way to do it?
Thank you,
Elena
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2022 07:33 AM
Since you mentioned your UI action is server side; you can try to use this to detect if it's form or list
var tableName = 'incident'; // give your table name here
var isForm = gs.action.getGlideURI().toString().indexOf(tableName + '.do') > -1;
if(!isForm){
var url = current.getTableName()+'_list.do';
action.setRedirectURL(url);
}else{
action.setRedirectURL(current);
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2022 07:05 AM
Hi
Check the below link
https://community.servicenow.com/community?id=community_question&sys_id=ec1d8b69db9cdbc01dcaf3231f961933
Thanks
Chandu Telu
Please Mark ✅ Correct/helpful, if applicable,

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2022 07:28 AM
Hello,
Thank you for your answer! I checked the link and it isn't exactly what I need. My code in the UI action is server side.
Thank you,
Elena
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2022 07:26 AM
Hi,
you can determine the URL and know if it's form or list in client side
Is your UI action purely server side?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2022 07:32 AM
Hi Ankur,
My code is purely server side.
It worked good for the form but I have a new requirement that needs to calculate "delta" for more records in a list.
I can create a similar UI action for list, that has a different redirect but I thought there is another solution to utilize the existing one.
Here is the code:
var addendumSysId = current.sys_id.toString();
var addendumChangeDate = current.u_change_date;
var addendumValEndDate = current.u_price_validity_end_date;
new AddendumTotalValue().calculateDelta(addendumSysId, addendumChangeDate, addendumValEndDate);
action.setRedirectURL(current);
What do you think is the best practice?
Thank you,
Elena