Mandate attachment of evidence of change completion before closing the ticket

Anupriya_11
Tera Contributor

Hi Team, I have a requirement below in details:

 

AC1: Upon clicking the Review button, pop-up message will appear to remind them to attach evidence of change completion.

Pop-up Message: "Please attach proof of change completion."

If users have already uploaded the evidence, they just have to re-attach the file.

AC2: This should be mandatory to ALL Types of Change (Normal, Emergency, & Standard), and they won't be able to close the ticket.

 

I am still in learning phase, can someone help me how to achieve this. 

 

Thanks in advance.

 

3 REPLIES 3

Vishal Jaswal
Giga Sage

Hello @Anupriya_11 

1. You should discuss with your stakeholder to modify the requirements related to proof of change completion file. For example: This attachment should be either a doc or a pdf and should only be allowed to be uploaded when the Change State is Implement.

2. When you click Review, you want to check whether this file alread exists or not - Imagine you click Review, you attached the file because of the pop up and then you click review again and file exists because you just uploaded it however checking file exists or not logic will again kick in and will be in never ending loop.
3. So discuss with your stakeholder that such file name should only be allowed to upload when state is implement - You need to develop this logic or the first click on Review UI Action will check the attachment with a specific name of the file and if that exists then it will move the state to Review or if file do not exists then will ask to upload the file. Once uploaded then review will be clicked again and this time because you recently uploaded the file, the logic will move the state from Implement to Review.


It is always good for a new learner to develop something using their ServiceNow Fundamentals and Application Developer skills which are free On Demand courses available for everyone in Now Learning portal: 

https://learning.servicenow.com/lxp/en/now-platform/servicenow-administration-fundamentals-on-demand... 
https://learning.servicenow.com/lxp/en/now-platform/application-development-fundamentals-on-demand?i... 

For example: To meet this requirement:
Step#1: you need pop up: learn GlideModal and UI page
Step#2: validation whether the attachment with such name format exists or not: learn Script Include
Step#3: To call a script include, I need to write client side: Learn UI actions and Widgets are such features of ServiceNow which can execute both client side and Server Side.

So, I encourage you to develop something and share what is working for you and what is not.



Hope that helps!

Edxavier Robert
Mega Sage

Hi @Anupriya_11 , 

 

You will need to use GlideAjax to call a Script Include that checks if the current record has attachments. For example: 

var CheckChangeAttachments = Class.create();
CheckChangeAttachments.prototype = Object.extendsObject(AbstractAjaxProcessor, {
    hasAttachments: function () {
        var sys_id = this.getParameter('sys_id');
        var gr = new GlideRecord('sys_attachment');
        gr.addQuery('table_name', 'change_request');
        gr.addQuery('table_sys_id', sys_id);
        gr.setLimit(1);
        gr.query();
        return gr.hasNext() ? 'true' : 'false';
    }
});

EdxavierRobert_0-1745096712716.png

 

The on the change table, you may want to clone the OOB ui action Review ( so don't modify the existing one) and call the script include, and keeping the existing logic. 

function moveToReview() {
var ga = new GlideAjax('CheckChangeAttachments');
    ga.addParam('sysparm_name', 'hasAttachments');
    ga.addParam('sys_id', g_form.getUniqueValue());
    ga.getXMLAnswer(function(response) {
        if (response === 'false') {
            alert("Please attach proof of change completion.");
        } else {
            g_form.setValue("state", "0");
            gsftSubmit(null, g_form.getFormElement(), "state_model_move_to_review");
        }
		if (typeof window == 'undefined')
    setRedirect();

function setRedirect() {
    current.update();
    action.setRedirectURL(current);
}
    });
}

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards
Edxavier

Ankur Bawiskar
Tera Patron
Tera Patron

@Anupriya_11 

on which form? share some screenshots?

you didn't share the details

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader