How to Create Standard Change from SCTASK and that SCTASK number should be link to change Reuqest
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago - last edited 3 hours ago
I have created a UI Action on the sc_task table and added the below code for Creating a Standard Change:
var url = new StdChangeUtils().getURLForTask(current, 'rfc');
url += '&sc_task_sys_id=' + current.sys_id;
action.setRedirectURL(url);
It is redirecting to standard change template for creating new change request but linkage of sctask is not happening on that change request parent field.
Question:
Is there a way to implement this functionality so that the originating SCTASK is linked to the Change Request created via the Standard Change template?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
create this onLoad client script and grab the sysId and set in parent field
Note: ensure parent field is present on the form view
function onLoad() {
var gUrl = new GlideURL();
gUrl.setFromCurrent();
var taskSysId = gUrl.getParam("sc_task_sys_id");
g_form.setValue('parent', taskSysId);
}
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
This parameter giving undefined value
var url = new StdChangeUtils().getURLForTask(current, 'rfc'); url += '&sc_task_sys_id=' + current.sys_id; action.setRedirectURL(url);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
it worked for me now
Update your UI action as this -> don't send task sysId, no need of this
var url = new StdChangeUtils().getURLForTask(current, 'rfc');
action.setRedirectURL(url);
client Script as this -> the task sysId is already present in URL, use regex and grab that and set
function onLoad() {
//Type appropriate comment here, and begin script below
var url = top.location.href;
var regex = /sysparm_processing_hint=table:sc_task;sysid:([a-f0-9]{32})/;
var match = url.match(regex);
if (match && match[1]) {
var taskSysId = match[1];
alert(taskSysId);
// Use sysId as needed
}
}
Output:
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader