Need to Show Service Catalog item in custom Service portal widget!

VikramM1
Tera Contributor

I want to create a catalog item with a variable which accepts date. Same should show in Service Portal Custom Widget.

 

Below conditions to be applied in Service Portal Widget when user selects date and submit:

When user requests a catalog item, it should check if the date entered in date variable is it from past. If yes, then it should display one alert message, and it should clear the value from date field and abort the submission. 

2 ACCEPTED SOLUTIONS

Ankur Bawiskar
Tera Patron
Tera Patron

@VikramM1 

I didn't get this part -> Same should show in Service Portal Custom Widget.

You can validate date entered in date variable is in past using Catalog UI policy

No Code date validations through (Catalog) UI Policies 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

Danish Bhairag2
Tera Sage
Tera Sage

Hi @VikramM1 ,

 

U can create a variable of type Date & Make it mandatory. U can create UI policy where condition can be date_field before today n then in script section select UI type as ALL & under Execute if true u can write below command.

 

alert('Past Date cannot be selected');
g_form.clearValue('date_field');

 

As it is mandatory after clearing the value it will again become mandatory hence will force user to enter proper date before form submission.

 

Thanks,

Danish

 

View solution in original post

2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

@VikramM1 

I didn't get this part -> Same should show in Service Portal Custom Widget.

You can validate date entered in date variable is in past using Catalog UI policy

No Code date validations through (Catalog) UI Policies 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Danish Bhairag2
Tera Sage
Tera Sage

Hi @VikramM1 ,

 

U can create a variable of type Date & Make it mandatory. U can create UI policy where condition can be date_field before today n then in script section select UI type as ALL & under Execute if true u can write below command.

 

alert('Past Date cannot be selected');
g_form.clearValue('date_field');

 

As it is mandatory after clearing the value it will again become mandatory hence will force user to enter proper date before form submission.

 

Thanks,

Danish