- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2024 08:42 AM
Hello,
The blow business rule script currently trigger on RITM table and successfully creates a new task. However, I'm struggling to redirect it to the newly created record. Could someone please review the code and offer suggestions on how to make this work?
Your assistance would be greatly appreciated.
(function executeRule(current, previous /*null when async*/ ) {
if (current.description == 'software') {
var gr = new GlideRecord('sc_task');
gr.initialize();
gr.request_item = current.sys_id;
gr.short_description = 'New task for software request';
gr.description = 'test';
// Insert the new record and get the sys_id
var newRecordSysId = gr.insert();
if (newRecordSysId) {
gs.addInfoMessage('New task ' +gr.number);
// Redirect to the newly created record
action.setRedirectURL('/sc_task.do?sys_id=' + newRecordSysId);
} else {
gs.addErrorMessage('Failed to create the record.');
}
}
})(current, previous);
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2024 11:44 AM
@Meera_P Yes, you can create an info message and add the link of your record to it. Here is how you can do it https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0691931

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2024 08:45 AM
You can't redirect user using business rules. Business rule scripts runs on the server side and can't be used for the refirection.
action.setRedirectURL
Redirection can only be done from a UI Action. For more information please refer to https://developer.servicenow.com/dev.do#!/reference/api/xanadu/server/no-namespace/ActionAPIBoth#Act...
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2024 09:54 AM
Thank you for the information @Sandeep Rajput ,
Any suggestions how we can handle this situation?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2024 10:58 AM
@Meera_P The operation you are trying to perform should ideally be part of a UI Action, instead of a business rule.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2024 11:03 AM
If we can not perform this function in BS. How about can we add a link to the message like in change request after newly created record? Just wanted to know if that is possible option. Thank you