How to display the calendar exactly one year from day of request submission

taqdeer
Tera Contributor

Hi All,

I want to display the data/time exactly one year from the day of request submission.
Currenlty, I am using the variable type as Date/Time but please help me to display exact one year.

taqdeer_0-1679571161632.png

 

Question : Duration of exception
Name : duration_of_exception

 

 

 

5 REPLIES 5

Kalyani Jangam1
Mega Sage
Mega Sage

Hi You can OnSubmit Catalog client script for below code

 

************Client script*************************************

function onSubmit() {
var gr = new GlideAjax('Validation');
gr.addParam('sysparm_name', 'setDate');
gr.getXML(PopulateDate);

function PopulateDate(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
g_form.setValue('start_date',answer);
}

}

*****************SI Code*****************************************************

setDate: function() {
var num = new GlideDateTime().getTime();
return num;
},

 

Please check and let me know if it helpful or not

Hi Kalyani,

 

Thanks for the reply.
It doesn't work.
I am getting this error.

taqdeer_0-1679575899120.png
Also, I am getting the same error for the script include code also.

Hi @taqdeer 

Please confirm you select OnSubmit Client script or delete this one and try once on new OnSubmit.

taqdeer
Tera Contributor

Hi Kalyani,
Is there any way that I can display the two columns from a table in the reference type variable on a catalog item in servicenow?

 

taqdeer_0-1680097970847.png

In the abave example only name is being displayed however we also want to display the code prior to it