After the attachment attached in the RITM form it should create sc_task

Gayathree Seeth
Tera Expert

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!!

2 ACCEPTED SOLUTIONS

Hi @Gayathree Seeth,

So as stated earlier for this you need to have client script as well as script include.

Client Script :

JohnsMarokky_0-1681148247708.png

 

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:

JohnsMarokky_1-1681148356950.png

 

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

View solution in original post

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

View solution in original post

10 REPLIES 10

Thanks Johns for the reply,

 

Please take your time. I am waiting in this.

 

 

Hi @Gayathree Seeth,

So as stated earlier for this you need to have client script as well as script include.

Client Script :

JohnsMarokky_0-1681148247708.png

 

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:

JohnsMarokky_1-1681148356950.png

 

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

Thanks very much Johns!!

This really helped. 

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.

 

 

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