We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

How to Set Dafult value in the date picker Service Portal

Sree Sudhan
Tera Contributor

I want to prefill today's date in the date picker field in the Service Portal. Is there a possibility?

Html
<sp-date-picker field="::spDatePickerConfig.startTime || {}" sn-min-date="min" ng-model="start.value" sn-include-time="false" sn-change="timeChange(start)"> </sp-date-picker>

client script:

var c = this;

$scope.min = new Date();

$scope.timeChange = function(start) {
c.data.enteredDateTime = start.value;
c.data.action = "checkStartDate";
c.server.update();
}
3 REPLIES 3

Ankur Bawiskar
Tera Patron

@Sree Sudhan 

where are you using that? on catalog form?

please share some details

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

Hi @Ankur Bawiskar ,

I am doing it on the service portal custom widget!

This Date picker field should be prefilled with today's date.
image (13).png

@Sree Sudhan 

why to have custom widget when you have already OOB date variable?

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