- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2021 01:28 PM
I'm trying to add a custom button (called submit) on a form widget . When I click the button , it doesn't look like anything is happening . I also don't see any errors .
When the user clicks the submit button , its supposed to update the state , date and submitter fields in the backend for the demand record being viewed.
HTML:
<button type="submit" ng-click="confirmsubmit()" class="btn btn-primary action-btn pull-right" >${Submit} </button>
Client Side Script :
function confirmsubmit(){
current.state = '2';
current.submitted_date = gs.now();
current.submitter = gs.getUserID();
current.update();
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2021 06:31 PM
There are a few things here.
Even in a widget you don't have access to perform server-side script actions in a client script. You need to pass data to the server script to execute server side. You also don't have immediate access to "current" - you have to define it.
Some of this is just a guess based on what you describe, but give something like this a try:
Server Script should look something like this (or should at least include these elements)
(function($scope, $sp) {
/* populate the 'data' object */
/* e.g., data.table = $sp.getValue('table'); */
if (input) {
if(input.action == 'updateCurrent') {
var current = new GlideRecord('dmn_demand');
current.get(input.sys_id);
current.state = '2';
current.submitted_date = gs.now();
current.submitter = gs.getUserID();
current.update();
}
}
})();
Client Side should look like this: (be sure to pass in $scope and $location !)
api.controller = function($scope, $location) {
/* widget controller */
var c = this;
$scope.confirmsubmit = function() {
var input = {};
input.action = 'updateCurrent';
input.sys_id = $location.search().sys_id;
c.server.get(input).then(function(r) {
//just for testing
alert('Success ' + r.data.current);
});
};
};
I hope this helps!
If this was helpful or correct, please be kind and remember to click appropriately!
Michael Jones - Proud member of the CloudPires team!
Michael D. Jones
Proud member of the GlideFast Consulting Team!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2021 05:02 PM
Just an update , I am finally getting the button to generate the pop up window . I had to create a widget and then create a macro in my record producer . It looks like I was putting the codes in the wrong place .
Thanks again for your help !!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2021 05:03 PM
Just an update , I am finally getting the button to generate the pop up window . I had to create a widget and then create a macro in my record producer that references the widget. It looks like I was putting the codes in the wrong place .
Thanks again for your help !!!