sp-date-picker validation on ServicePortal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2022 01:34 PM
I have created start date and end date field using angular ng template using the below code.
<sp-date-picker
field="::spDatePickerConfig.startTime || {}"
ng-model="start.value"
sn-include-time="true"
sn-change="timeChange('start')">
</sp-date-picker>
I want that if the user selects a time outside office hours 9am-6pm , he should be asked to select time between office hours.
And if the user selects the time in the office hours but that time is already past, the next day's date should populate automatically.
How can I achieve this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2022 06:23 AM
<wsd-search-filter
mode="c.mode"
location-tree-data="c.data.location_tree_data"
reservation="c.reservation"
start="c.start"
end="c.end"
day-start="c.data.dayStart"
day-end="c.data.dayEnd"
page-size="c.options.page_size"
init-config="::c.data.initSearchConfig"
is-multi-item-selection="c.selectedItems.length > 1"
disable-change-location="c.isChangeLocationDisabled()"
disable-change-module="c.isEditing || c.selectedItems.length >= 1"
types = "c.data.reservable_modules"
translations = "c.data.translations">
</wsd-search-filter>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2022 06:28 AM
@Kalik1 Its angular provider. Please post angular provider code.
ServiceNow Community Rising Star, Class of 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2022 07:34 AM
@Kalik1 Please write the client side function in controller of angular provider
Code needs some update as below. c should be changed to $scope.
$scope.timeChange = function(start){
$scope.data.enteredDateTime = start.value;
$scope.data.action = "checkStartDate";
$scope.server.update().then(function(resp){
if(resp.message){
alert(resp.message)
}
if($scope.data.isOldDate){
alert("Entered date is past date, setting to new date")
start.value = $scope.data.newDate;
}
})
}
Please try this, this should solve your issue.
Please mark as correct answer if this solves your issue.
ServiceNow Community Rising Star, Class of 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2022 06:24 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2022 06:27 AM