- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2022 10:27 AM
When the user clicks the update button with the date/time, that value should update a field in the incident table.
Html........
<div>
<form>
<sp-date-picker name="mydata" sn-include-time=true field="c.fromDate" ng-model="c.fromDate.value" ></sp-date-picker>
<div class="m-t-lg">
<button class="btn btn-primary pull-right" ng-click="UpdateData()">
${Update}
</button>
</div>
</form>
</div>
Client side....
api.controller=function($scope) {
/* widget controller */
var c=this;
c.fromDate = {
displayValue: '',
value: c.data.mydata,
name: ''
};
$scope.UpdateData = function(){
c.server.update();
}
}
Server side
(function() {
// If input is submitted then grab any input values from input fields
// based on their names (name attribute on element)
// and update this case a record
if(input){
var inc1 = new GlideRecord('incident');
inc1.get(sys_id);
inc1.setValue('field_name', input.mydata);
inc1.update();
}
})();
Solved! Go to Solution.
- Labels:
-
Service Portal Development

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2022 02:12 PM
Hello Ed,
Solution tested in a PDI!!
Change your client script by the following one:
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);
}
}
Basically, I declared object "input" and instead of c.server.update() I used c.server.get(input).
It worked!
Please mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!
Best Regards,
Filipe Cruz

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2022 02:12 PM
Hello Ed,
Solution tested in a PDI!!
Change your client script by the following one:
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);
}
}
Basically, I declared object "input" and instead of c.server.update() I used c.server.get(input).
It worked!
Please mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!
Best Regards,
Filipe Cruz
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2022 12:29 AM
One issue I have noticed is that if I select a date/time like this below-
but after updating the data, it updates that field value with 03-11-2022 18:08:29
any solution for this??