- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2017 07:24 AM
The Change team has made a request to reference the original change number when someone uses the Copy Change UI Action. I create a field called u_original_change on the change form and made it read only. I added a snippet of code into the Copy Change UI Action to copy the orginal change number to a variable, but am unsure what code and where to place it to paste it into the new form that is created. Does anyone have any pointers?
function OnCopyChangeClick() {
function addParam(form, name, val) {
var inp = cel('textarea', form);
inp.name = name;
inp.value = val;
}
var srcSysId = g_form.getUniqueValue();
//added by T8
var origChange = g_form.getValue('number');
//end added by T8
var ga = new GlideAjax('ChangeUtils');
ga.addParam('sysparm_name', 'getChangeQueryParams');
ga.addParam('sysparm_src_sysid', srcSysId);
ga.setWantSessionMessages(true);
ga.getXMLAnswer(function (queryParam) {
if (queryParam) {
var gotoUrl = [];
gotoUrl.push('srcSysID=' + srcSysId);
gotoUrl.push('newSysID=$sys_id');
gotoUrl.push('sysparm_returned_action=$action');
gotoUrl = 'CopyChangeRelatedLists.do?' + gotoUrl.join('&');
var form = cel('form', document.body);
hide(form);
form.method = "POST";
form.action = g_form.getTableName() + ".do";
if (typeof g_ck != 'undefined' && g_ck != "")
addParam(form, 'sysparm_ck', g_ck);
addParam(form, 'sys_id', '-1');
addParam(form, 'sysparm_query', queryParam);
addParam(form, 'sysparm_goto_url', gotoUrl);
form.submit();
}
});
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2017 09:42 AM
Hi,
It seems the UI Action won't help, The value is saved at front end UI but it is not available at database when a new change is copied. You can try adding this before insert business rule with condition as Original Number is empty and script as
current.u_original_change = current.sys_id;
Thanks
Please Hit like, Helpful or Correct depending on the impact of the response.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2017 08:19 AM
Hi Tate,
The related script include(ChangeUtilsSNC) that copy values are locked by Service Now and I am not sure if there is a way to modify the UI Action. There is a workaround to get this done. Update the u_original_change field with the parent change number and add this field in the system property "com.snc.change_request.copy.attributes".
When change is copied, the value in this field will be copied to the cloned change. Please let me know if it helps.
Thanks
Please Hit like, Helpful or Correct depending on the impact of the response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2017 09:18 AM
Thank you, I'm getting closer. I changed the first part of the Copy Change UI Action to this;
var srcSysId = g_form.getUniqueValue();
//added by T8
var origChange = g_form.getValue('number');
if (g_form.getValue('u_original_change') == "") {
g_form.setValue ('u_original_change', origChange);
g_form.save();
}
//end added by T8
I also went under Change > Change Properties and added u_original_change to the end of the List of attributes list and Saved.
When I click on Copy Change, it copies the Number to the u_original_change field and saves it, but the new record is still missing the value after it is created. If the field is populated before the Copy Change command it successfully copies over the value present. I'm still missing something.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2017 09:42 AM
Hi,
It seems the UI Action won't help, The value is saved at front end UI but it is not available at database when a new change is copied. You can try adding this before insert business rule with condition as Original Number is empty and script as
current.u_original_change = current.sys_id;
Thanks
Please Hit like, Helpful or Correct depending on the impact of the response.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2017 02:51 AM
Hi Tate,
Were you able to check this out?
Thanks
Please Hit like, Helpful or Correct depending on the impact of the response