- 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
‎07-17-2018 07:38 AM
My recommendation would be to 'Insert and Stay' to make a copy of the UI Action and then make the changes so you aren't modifying anything OOTB as it could potentially impact future upgrades.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-17-2018 07:39 AM
I was planning on creating a copy of the OOB UI Action and modifying the copy, for the exact reason.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-18-2018 04:06 AM
Hi Ian,
I was reading this thread and I have a requirement to pass the current Change request number and update the work notes with that number.
Could you please let me know how do I pass the current change request number?
I am trying like this and it's printed the comment but couldn't able to pass the current change request number.
addParam(form, 'sysparm_query', queryParam + '^u_copied_change=true' +'^work_notes =This Change has been copied from:' + ????????);
Any help will be much appreciated!!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-18-2018 04:27 AM
Hi Ian,
I have sorted out.
Though Thank You.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-01-2020 05:22 AM
Hello Manish, could you please explain how you managed to achieve this requirement? Please paste the code snippet as I have a similar kind of requirement.
Thanks,
Mahesh