- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-18-2022 07:51 AM
Hello,
I have created a date picker in widget that will take input date from user. The date picked by the user updates a field in Approval table. But it is updating wrong date, it is updating one previous date like if I enter 24 it updates 23 in that field of Approval table. What am I missing?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-18-2022 10:34 AM
Try this code
HTML
<sp-date-picker name="mydata" sn-include-time=false field="c.fromDate" ng-model="c.fromDate.value" ></sp-date-picker>
<button class="btn btn-primary" ng-click="UpdateData()">
${Save}
</button>
Client
api.controller=function($scope) {
/* widget controller */
var c=this;
c.fromDate = {
displayValue: '',
value: c.data.myInput,
name: ''
};
$scope.UpdateData = function(){
var input = {};
input.myInput = c.fromDate.value;
c.server.get(input);
}
}
Server
(function() {
if(input){
var inc1 = new GlideRecord('your_table');
inc1.get('recordSysID');
inc1.setValue('yourDateField', input.myInput);
inc1.update();
}
})();
Works for me when i tested
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-18-2022 09:10 AM
If you post the code for your widget, we can take a look
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-18-2022 09:29 AM
Hi Mike,
Actually, I copied everything same from this link "How to create a Save button in Service portal view... - ServiceNow Community
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-18-2022 09:31 AM
The difference is that in the widget the input is of type "date" in HTML.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-18-2022 10:34 AM
Try this code
HTML
<sp-date-picker name="mydata" sn-include-time=false field="c.fromDate" ng-model="c.fromDate.value" ></sp-date-picker>
<button class="btn btn-primary" ng-click="UpdateData()">
${Save}
</button>
Client
api.controller=function($scope) {
/* widget controller */
var c=this;
c.fromDate = {
displayValue: '',
value: c.data.myInput,
name: ''
};
$scope.UpdateData = function(){
var input = {};
input.myInput = c.fromDate.value;
c.server.get(input);
}
}
Server
(function() {
if(input){
var inc1 = new GlideRecord('your_table');
inc1.get('recordSysID');
inc1.setValue('yourDateField', input.myInput);
inc1.update();
}
})();
Works for me when i tested