Planned leave should be applied only after one week from present date

DhanrajCh
Tera Contributor

Hi, if employee is applying the leave and if the type of leave = planned then the start date should be highlight after one week from the present date. 

for the above question i need in client script.

Thanks .

4 ACCEPTED SOLUTIONS

piyushsain
Tera Guru
Tera Guru

Hi,

It is not possible to highlight particular dates in the calendar, you have to apply the conditions in the client script after user selects the dates.

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,
Piyush Sain

View solution in original post

Sonam Tiwari
Tera Guru

Hi @DhanrajCh 

If I am understanding your question right then I think below should be of help to you. Check this article once.
https://www.servicenow.com/community/developer-articles/no-code-date-validations-through-catalog-ui-...

You can add an additional condition where type of leave is planned and modify the condition for your date valiation to 1 week.


View solution in original post

Samaksh Wani
Giga Sage
Giga Sage

Hello @DhanrajCh

 

You need to OnChange Client Script :-

 

 

 

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}

var leave = g_form.getValue('type_of_leave');

if(leave == "Planned"){
var d = new Date();
d.addDays(7);
g_form.setValue('start_date', d);
}
}

 

 

 

 

Plz Mark my Solution as Accept and Give me thumbs up, if you find it Helpful.

 

Regards,

Samaksh

 

 

 

 

View solution in original post

Use this :-

 

var today_date = new Date();

@DhanrajCh  

View solution in original post

4 REPLIES 4

piyushsain
Tera Guru
Tera Guru

Hi,

It is not possible to highlight particular dates in the calendar, you have to apply the conditions in the client script after user selects the dates.

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,
Piyush Sain

Sonam Tiwari
Tera Guru

Hi @DhanrajCh 

If I am understanding your question right then I think below should be of help to you. Check this article once.
https://www.servicenow.com/community/developer-articles/no-code-date-validations-through-catalog-ui-...

You can add an additional condition where type of leave is planned and modify the condition for your date valiation to 1 week.


Samaksh Wani
Giga Sage
Giga Sage

Hello @DhanrajCh

 

You need to OnChange Client Script :-

 

 

 

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}

var leave = g_form.getValue('type_of_leave');

if(leave == "Planned"){
var d = new Date();
d.addDays(7);
g_form.setValue('start_date', d);
}
}

 

 

 

 

Plz Mark my Solution as Accept and Give me thumbs up, if you find it Helpful.

 

Regards,

Samaksh

 

 

 

 

Use this :-

 

var today_date = new Date();

@DhanrajCh