issue related to display value of Created field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2024 02:51 AM
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 ?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2024 02:59 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2024 03:03 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2024 03:30 AM
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
- Get the values of those fields using g_form
- Pass those into getDateFromFormat - this is a global function available to you
- Get the difference between those dates https://www.30secondsofcode.org/js/s/date-difference/