- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2022 08:31 PM
Hi,
I am trying to copy attachment to change request when a sys_template is applied?
Found couple of post where it is suggested to create a new filed on change request which refers to sys_template field, but wondering how to get this field auto populated when the sys_template is applied from toggle bar?
Please suggest best way to implement this solution? thank you
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2022 10:58 PM
Thank you @Murthy Ch.
Created an additional field on Change request table which will be used to copy the template name when the template is applied. Created a BR on sys_template table which will map the existing template to the new field on change request, so whenever the template is applied, the new field get's populated and I have reference to template from which I can copy the attachment to CR using the GlideSysAttachment.copy method.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2022 09:10 AM
I think finding an which template is applied is difficult. So there will be some fields will set via Template.
So use the unique value of the field which you are mapping.
Let's say in my case I'm copying the attachment when short description changes and when template is applied. (short description is unique here)
Field name Short Description in CS
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if (isTemplate && g_form.getValue("short_description") == "Applying template") { //when template applied and short description is unique
var ajax = new GlideAjax('Newglidingabc');
ajax.addParam('sysparm_name', 'copyAttachmentwhenTemp');
ajax.addParam('sysparm_existing', g_form.getUniqueValue());
ajax.getXML(getRITMdata);
}
function getRITMdata(response) {
// do nothing...
}
}
copyAttachmentwhenTemp: function() {
GlideSysAttachment.copy("sys_template", "4b175dd20a0a0b99004f35e506563fc6", "change_request", this.getParameter("sysparm_existing"));
},
//store the attachment in template record and call it here...
Hope it helps..
Murthy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2022 10:58 PM
Thank you @Murthy Ch.
Created an additional field on Change request table which will be used to copy the template name when the template is applied. Created a BR on sys_template table which will map the existing template to the new field on change request, so whenever the template is applied, the new field get's populated and I have reference to template from which I can copy the attachment to CR using the GlideSysAttachment.copy method.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2022 11:05 PM
yes you can like that but it will require a new field creation. In my example it doesn't require to create a new field if any field value is unique:)
Murthy