Incident form : how to set state inprogess when two date fields are there

chandan2212
Tera Contributor

Hi All,

 

There are two fields are there one is   due date and duedate1.

 

field :due date it is selected user.

field: duedate1 showing current date 

 

I got the requirement when due date field is greater than due date 1 than state of the incident form should go to in progress .

Can you tell me how to achieve this requirement.

 

Thanks ,

Chandan

1 ACCEPTED SOLUTION

Sohail Khilji
Kilo Patron
Kilo Patron

Hi @chandan2212 

 

did you start working on it ? were are you struck >

 

You can got to create a onchange client script , someting like below..

var dtStartForm = g_form.getValue('your_field1');

var dtStart = getDateFromFormat(dtStartForm,g_user_date_time_format);

if (dtStartForm != '') {

       var dtEndForm = g_form.getValue('your_field2');

       var dtEnd = getDateFromFormat(dtEndForm, g_user_date_time_format);

       if (dtEnd > dtStart) {

               g_form.setValue('state', '3'); // set the value for inprogress

       }

}

☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

View solution in original post

3 REPLIES 3

Sohail Khilji
Kilo Patron
Kilo Patron

Hi @chandan2212 

 

did you start working on it ? were are you struck >

 

You can got to create a onchange client script , someting like below..

var dtStartForm = g_form.getValue('your_field1');

var dtStart = getDateFromFormat(dtStartForm,g_user_date_time_format);

if (dtStartForm != '') {

       var dtEndForm = g_form.getValue('your_field2');

       var dtEnd = getDateFromFormat(dtEndForm, g_user_date_time_format);

       if (dtEnd > dtStart) {

               g_form.setValue('state', '3'); // set the value for inprogress

       }

}

☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @chandan2212 

 

You can do as suggested by @Sohail Khilji  expert or you can use state model as well or may be UI policy and use script to set the State field. but client script is good option. 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Amit Pandey
Kilo Sage

Hi @chandan2212 

 

You can use following onChange Client Script-

var start = g_form.getValue('your_field1');
var end = g_form.getValue('your_field2');

if (start && end && (new Date(end) > new Date(start))) {
    g_form.setValue('state', '3'); // set the value for inprogress
}

Please mark this correct and helpful.

 

Regards,

Amit