Where to add action.setRedirectedURL(current) in client callable UI action.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2024 06:38 AM - edited 12-13-2024 07:15 AM
Hi all, My client callable UI action is being redirected to other page. I used action.setRedirectURL(current) but it is still being redirected to other page. Please refer below code.
function doIt() {
if (confirm("Are you sure")) {
//alert("You clicked yes");
gsftSubmit(null, g_form.getFormElement(), 'populate');
}
}
if (typeof window == 'undefined')
updateRecord();
function updateRecord() {
var inputs = {};
inputs['table_name'] = 'incident';
inputs['incident'] = current;
// Start Asynchronously: Uncomment to run in background.
sn_fd.FlowAPI.startFlow('global.Test Inc', inputs);
action.setRedirectURL("https://dev223110.service-now.com/incident.do?sys_id=57af7aec73d423002728660c4cf6a71c");
// Execute Synchronously: Run in foreground.
//sn_fd.FlowAPI.executeFlow('global.[internal name of flow]', inputs);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2024 08:48 AM
I might be mistaken, but I believe action is reserved for server-side code only. Try using window.open(url) and set your variable url equal to '/incident.do?sys_id=....' (basically everything after instance-name.com).
(I am assuming you have hard-coded your redirect URL for testing purposes in the script you shared above.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2024 09:11 AM
Hi @Obito ,
Chaitanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2024 09:13 AM - edited 12-14-2024 06:41 AM
Hi @Obito,
When passing the URL within the method, you do not need to reference the instance name and domain. simply pass the paramter or string of "/incident.do?sys_id=57af7aec73d423002728660c4cf6a71c".
I would however recommend against hard coding the sys_id. This should be declared as a varable and using dynamically.
Eg: action.setRedirectURL("/incident.do?sys_id=" + varriableNameOfsysID);
If you haven't already seen this SN Docs article on the implementation of a UI action (and importantly how a UI action uses both a client side and server side code) - check the following link:
To help others (and for me to gain recognition for my efforts), please mark this response correct by clicking on Accept as Solution and/or Kudos.
Thanks, Robbie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2024 09:38 AM - edited 12-13-2024 09:47 AM
Hi @Obito ,
Whatever you written after if(typeof window==“ undefined”) is serverside if you want server side use below one
action.setRedirectURL("/incident.do?sys_id=“+ sys_id variable name);
if you want in client side use below
var url = '"https://dev223110.service-now.com/incident.do?sys_id=57af7aec73d423002728660c4cf6a71c";
top.window.open= url;
If my response helped, please mark it as the accepted solution ✅ and give a thumbs up👍.
Thanks,
Anand