- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-17-2018 06:45 AM
The OOB UI Action Copy Change works very well, especially that it includes all related list items. However, I am trying to figure out how to modify it so that, on the newly created Change, a checkbox is set 'true' to indicate that the UI Action was used to create it.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-17-2018 07:31 AM
In the Copy Change UI action, add the name of your true/false field to the line "addParam(form, 'sysparm_query', queryParam);" and set it to true. For me this was line 30:
Example:
addParam(form, 'sysparm_query', queryParam + '^u_custom_field_name=true');
Full script:
function OnCopyChangeClick() {
function addParam(form, name, val) {
var inp = cel('textarea', form);
inp.name = name;
inp.value = val;
}
var srcSysId = g_form.getUniqueValue();
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 + '^u_copied_change=true');
addParam(form, 'sysparm_goto_url', gotoUrl);
form.submit();
}
});
}
I added a UI Policy to set the checkbox as Read Only during my testing as well. Looks like you can use this trick for other fields as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-05-2023 11:42 PM
Hi jonnygrove,
Thanks, This solved my problem of copying the complete Planning tab while copying change ( including justification and implementation plan fields).
The code I added to the script:
//added code to get justification and implementation_plan value from form
var justification = g_form.getValue('justification');
var implementation_plan = g_form.getValue('implementation_plan');
//customizing this line of code to include implementation_plan & justification values to the newly created change
addParam(form, 'sysparm_query', queryParam + "^justification=" + justification + "^implementation_plan=" + implementation_plan);
Thanks.