Create a change from a Risk

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2024 12:13 AM
Hello.
I am aiming to create a UI action on the risk form (or mitigation task) for creating a change. The normal create change will work just fine (that is the OOTB UI action with 6 lines of code). However I would like to 1. create the change and 2. grab the change_requets record and put it in a reference field (u_change) on the risk form. I am trying the below script but it doesn't work. Can someone guide me:
1. This one works:
function openCreateChange() {
var sys_id = g_form.getUniqueValue();
var url = '/change_request.do';
url += '?sys_id=-1&sysparm_query=sn_risk_risk=' + sys_id;
g_navigation.openPopup(url);
}
This doesn't work:
function createChangeAndLink() {
var riskRecord = g_form.getUniqueValue();
var changeRecord = new GlideRecord('change_request');
changeRecord.setValue('short_description', 'Change for Risk: ' + riskRecord);
var changeSysId = changeRecord.insert();
if (changeSysId) {
var riskRecordToUpdate = new GlideRecord('sn_risk_risk');
if (riskRecordToUpdate.get(riskRecord)) {
riskRecordToUpdate.setValue('u_change', changeSysId);
riskRecordToUpdate.update();
}
}
var url = '/change_request.do';
url += '?sys_id=-1&sysparm_query=sn_risk_risk=' + riskRecord;
g_navigation.openPopup(url);
}
createChangeAndLink();
/Glenn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2024 02:39 AM
May I know, what is need to duplicate change data on Risk form?
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-07-2024 07:22 AM
If you are referring to the reference field it is just for the purpose of looking it up. No other duplication. Rather transfer of information to the change record.
/Glenn