- 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-20-2017 05:27 AM
Yes, I was able to go off of your suggestion to hopefully provide what the change team wants. I created a business rule that copies the Change Request Number into the Original Change field on insert of update if it is empty, and to make it less confusing for users I created a UI policy to hide the field if it is either empty or when the numbers match. It only shows when the someone has copied a change.
Thanks so much!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2023 09:43 AM
Hello Tateroth,
Please elaborate how you did you achieve this.