Service Portal and \$sp.getRecord();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2016 08:09 AM
I'm trying to build a "detail" page where I can make RESTMessageV2 calls as a result of a user clicking a button. The challenge is that seemingly on subsequent calls either c.server.update() or spUtil.update($scope) from the client controller seem to empty out the data object when the server side function is called. Maybe this isn't the best way to do it, but I'd really like to take advantage of RESTMessageV2 if possible so I can reuse this in other places such as UI Action on the platform and keep things organized.
(function(){
// This seems to null out data?
var gr = $sp.getRecord();
if(gr){
data.canRead = gr.canRead();
if (!data.canRead)
return;
data.sys_id = gr.getUniqueValue();
}
// If someone clicks do action, $scope.data.doAction = 'yes';
// Then I call c.server.update();
if(data.doAction == 'yes'){
// Make my RESTMessageV2 call here.
}
})()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2016 08:57 AM
Hi Dan,
If you have to make a rest call I think you would want to do it from the client controller rather than the server. On the server side you wouldn't need to use rest, you could just call a script include.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2016 09:05 AM
I know I can do this all of the client side, but I'm calling a service external to servicenow, which means I then have to have a scheme to manage all of the endpoints, actions, and authentication in another place. My hope would be that I could use the outbound REST functionality to manage all of that for me, which has the benefit of keeping it organized as well as reusable in other places in the platform.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2016 11:07 AM
Think I somewhat answered my own question here. Reading the documentation here, I need to use input rather than data. Widget Server Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2016 09:20 AM
Please provide an example of how to update a field in a record using sputil.
