- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2025 01:12 AM
Please help me out in creating a change request from problem but not inserting it. Since the Ui action which creates a change record is saved through it that runs, the mandatory fields not filled in and continue to show as required. It should navigate to sys_is -1.
Below is the code and I have commented out line where it inserts.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2025 04:52 AM
you are not inserting so you won't get the CHG number
so these lines makes no point
var change = new GlideRecord("change_request");
change.short_description = current.short_description;
change.description = current.description;
change.cmdb_ci = current.cmdb_ci;
change.priority = current.priority;
change.company = current.company;
change.sys_domain = current.sys_domain;
change.parent = current.sys_id;
change.type = 'Normal';
//var sysID = change.insert();
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2025 01:42 AM
you want to create the CHG or want user to be taken to new record with pre-filled data?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2025 03:05 AM
Hello Ankur,
I want it to go to a new change record with prefilled data (few of fields) and wont create one. Once I fill in required fields (other than pre filled), I should submit it and then a change will be created.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2025 03:25 AM
then use this and send the fields in sysparm_query
I included for 2 fields, please enhance for other fields as well which you want to pre populate
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2025 03:41 AM
Hello Ankur I tried this earlier and once again now also, even though it doesnot create the change anymore, but after I submit it, it is not getting related to the problem. Means I cant find the change in problem related list. Do i need to remove any lines of code
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2025 03:50 AM
it is not meant to create new change, but will simply take user to the new CHG form with pre-filled data
that's what you wanted.
For that you can populate parent field of CHG with the current problem record sysId, so that it gets linked with the CHG. For this ensure parent field is present on the form. You can include that in URL like this
action.setRedirectURL("/change_request.do?sys_id=-1&sysparm_query=short_description=" + current.short_description + "^description" + current.description + '^parent=' + current.sys_id);
Now when you open Problem form in related list you will see that CHG as it's parent you already populated.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader