- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2023 09:41 AM
Hi,
When ITIL user changes the Approval field in the RITM form as approved then it should ask for the mandatory attachment in the Ritm form and then only the catalog tasks should be created.
Here, changing of the approval field is done using the ACL can you please suggest how that attachment can be made mandatory before creation of SC_task.
Thanks in Advance!!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2023 10:40 AM - edited 04-10-2023 12:04 PM
Hi @Gayathree Seeth,
So as stated earlier for this you need to have client script as well as script include.
Client Script :
var approval = g_form.getValue('approval');
if(approval == 'approved'){
var attachmentGA = new GlideAjax('checkForAttachment');
attachmentGA.addParam('sysparm_name', 'checkAttachment');
attachmentGA.addParam('sysparm_record_sysId', g_form.getUniqueValue());
attachmentGA.getXMLWait();
var attachmentNotExist = attachmentGA.getAnswer();
if (attachmentNotExist == 'true') {
alert("Madatory attachment Not added and the record will not be saved. Refreshing the page");
location.reload();
return false;
}
}
Script Include:
checkAttachment: function() {
var recordSysId = this.getParameter('sysparm_record_sysId');
var attachmentNotExist = false;
var attachmentGr = new GlideRecord('sys_attachment');
attachmentGr.addQuery('table_sys_id', recordSysId.toString());
attachmentGr.query();
if (!attachmentGr.next()) {
attachmentNotExist = true;
}
return attachmentNotExist;
},
Hope this helps.
Mark helpful and accept the solution if it helps in Solving your query.
Regards,
Johns
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2023 04:26 AM - edited 04-13-2023 04:29 AM
Hi @Gayathree Seeth,
if you use attachmentGr.getRowCount(); after attachmentGr.query(); in the script include it will give you the attachment count.
Mark helpful if it helps in solving your query.
Regards,
Johns
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2023 09:56 AM
Thanks Johns for the reply,
Please take your time. I am waiting in this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2023 10:40 AM - edited 04-10-2023 12:04 PM
Hi @Gayathree Seeth,
So as stated earlier for this you need to have client script as well as script include.
Client Script :
var approval = g_form.getValue('approval');
if(approval == 'approved'){
var attachmentGA = new GlideAjax('checkForAttachment');
attachmentGA.addParam('sysparm_name', 'checkAttachment');
attachmentGA.addParam('sysparm_record_sysId', g_form.getUniqueValue());
attachmentGA.getXMLWait();
var attachmentNotExist = attachmentGA.getAnswer();
if (attachmentNotExist == 'true') {
alert("Madatory attachment Not added and the record will not be saved. Refreshing the page");
location.reload();
return false;
}
}
Script Include:
checkAttachment: function() {
var recordSysId = this.getParameter('sysparm_record_sysId');
var attachmentNotExist = false;
var attachmentGr = new GlideRecord('sys_attachment');
attachmentGr.addQuery('table_sys_id', recordSysId.toString());
attachmentGr.query();
if (!attachmentGr.next()) {
attachmentNotExist = true;
}
return attachmentNotExist;
},
Hope this helps.
Mark helpful and accept the solution if it helps in Solving your query.
Regards,
Johns
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2023 03:23 AM
Thanks very much Johns!!
This really helped.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2023 01:55 AM
Hi Johns,
If i have an attachment already when submitted via portal in the RITM form, It should ask for the approval attachment again.
Suggest the code for checking the number of attachments attached.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2023 04:26 AM - edited 04-13-2023 04:29 AM
Hi @Gayathree Seeth,
if you use attachmentGr.getRowCount(); after attachmentGr.query(); in the script include it will give you the attachment count.
Mark helpful if it helps in solving your query.
Regards,
Johns