issue related to display value of Created field

Are Kaveri
Tera Contributor

Hello,

 

 

I am working for an custom incident form.

 

I got stuck for below validation.

 

there is Reassigned Date field (Date /Time)

There is Created field (Date/Time)

there is a Approver Comment field ( String)

 

There is a Escalate UI action.

 

On click of Escalate ,

if the duration between the Reassigned Date and Created is less than or equal to 12 months, Then display and make mandatory  Approver Comment.

if duration between the Reassigned Date and Created is less than or equal to 18 months, then don't display and don't make mandatory Approver comments 

 

Below is my script,

var gaAjax = new GlideAjax('gsn_incident');
        gaAjax.addParam('sysparm_name', 'sendForEscalateValidations');
        gaAjax.addParam('sysparm_incident', incident_sysid);
        gaAjax.getXMLAnswer(handleResponse);
    }

    function handleResponse(response) {
        var answer = response.toString();
        if (answer === '') {
            gsftSubmit(null, g_form.getFormElement(), 'escalate');

        } else {
            g_form.addErrorMessage(answer);
            return;
        }
    }

}

Script Include:

 sendForEscalateValidations: function() {
        var incident_sysid = this.getParameter('sysparm_incident');
      
        var error_msg = '';

        var incidentGR = new GlideRecord('gsn_incident');
        incidentGR.get(incident_sysid);

       
            error_msg += "Mandatory fields: Please add below Approver comments field" + '<br>';
        

        return error_msg;
    },

 

I need to add my validation in below script include.

how to get the duration in Months?

How to check the field display ?

3 REPLIES 3

Kieran Anson
Kilo Patron

Are the Reassigned Date and Created date fields on the form? if so, you can use a client side UI action and compute the date differences with the standard Date js function

@Kieran Anson 

 

could you please share script ???

yes both are present on my form.

 

I'm happy to help in educating, but I'm not doing the work for you...that doesn't help with your growth of learning.

Some pointers