- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2020 05:41 AM
Hi, wonder if anyone can assist with a custom widget which is doing the ticket update in the server script twice, but only intermittently and I cannot understand what is going on. I'm new to development and have based the code on the many helpful community posts, so may well be flawed!
I've tried the widget in a fresh dev instance (with the custom field created) and witness the same there.
Widget code as below any assistance greatly appreciated...
thanks in advance chris
HTML
<div>
<div class="panel panel-primary b" >
<div class="panel-heading">
<h4 class="panel-title pull-left">
${Test actions}
</h4>
<div class="clearfix"></div>
</div>
<div class="panel-body">
<button type="button" class="btn btn-success btn-block" ng-click="c.Chase('chase')" ng-disabled="clicked" >Request update</button>
</div></div></div>
Client script
function ($uibModal, $scope, spUtil, spModal) {
var c = this;
$scope.$on('record.updated', function(name, data) {
spUtil.update($scope);
});
c.Chase = function(action) {
$scope.clicked = true;
c.data.action = action;
c.server.update().then(function() {
c.data.action = undefined;
spUtil.addInfoMessage("An update has been Requested", 3000);
spUtil.update($scope);
}); } }
Server script
(function() {
data.table = input.table || $sp.getParameter("table");
data.sys_id = input.sys_id || $sp.getParameter("sys_id");
var gr = new GlideRecord(data.table);
if (!gr.isValid())
return;
if (!gr.get(data.sys_id))
return;
if (input && input.action) {
var action = input.action;
if (action === 'chase') {
var cc = gr.u_chase_call_counter;
gr.u_chase_call_counter = cc+1;
gr.comments = "An update has been requested";
// gr.setWorkflow(false);
gr.update();
} } })();
I tried gr.setWorkflow(false); but this just stopped the comments being posted to the record, the u_chase_call_counter still updated once/twice.
Solved! Go to Solution.
- Labels:
-
Service Portal Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2020 06:30 AM
This is due to the spUtil.update($scope); call in your callback function. In plain terms, what you're "c.Chase" is saying is, "run my server script, then once it's done, run the server script again".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2020 06:30 AM
This is due to the spUtil.update($scope); call in your callback function. In plain terms, what you're "c.Chase" is saying is, "run my server script, then once it's done, run the server script again".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2020 08:56 AM
Thanks Justin, removed it and seems to be working now
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2020 08:54 AM
Thanks Justin removing that has helped
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2020 05:32 AM
Can you please tell how you resolved this issue? I am facing the same problem
Thanks