
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-22-2018 10:26 PM
Hi Team,
I have a custom 'true/false' field called 'u_re_approval' which works with my workflow to send the HR Case for another round of approvals if rejected. All this works great, except I need the employee to also be able to update the field via the HR Portal interface.
The Page I updated is 'hrj_ticket_page' pointing to the widget 'hrj-case-info' and the button shows up all fine, but I can't get the code working correctly to set the value of this field to 'true'. I think it's the client and server code that isn't working and now sure why, any help is appreciated.
Widget HTML:
<button name="reapproval" class="btn btn-primary" style="margin-bottom: 20px" ng-click="reapprove();">Send for Re-Approval</button>
The above seems to work as the button is showing and when I press it the client statement console.log shows the current value.
Server Code:
// CJF 23-07-18 New server function for 'Send for Re-Approval' button for HR Training
function(){
// Send for Re-Approval
if (input && input.action){
var action = input.action;
if (action == 'reapprove'){
grCase.setValue('u_re_approve2', true);
grCase.update();
}
}
}
//CJF 23-07-18 - End of new function
Client Code:
// CJF 23-07-18
$scope.reapprove = function() {
console.log($scope.data.reApproval);
//$scope.data.reApproval = true;
//data.reApproval = grCase.getDisplayValue('u_re_approval');
$scope.server.update();
c.server.update().then(function(){
//$scope.update();
})
}
Hopefully it's only something simple...
Cheers
Carl.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-23-2018 07:20 PM
Try updating you script with below and check.
(function() {
gr = new GlideRecord('sn_hr_core_case');
gr.get(,$sp.getParameter('sys_id'));
if (input && input.action) {
var action = input.action;
if (action == 'reapprove') {
// Re-approve HR Case
gr.setValue('u_re_approve2', true);
gr.update();
}
//if (action == 'cancel') {
// // Do something else
// }
}
})();
Please mark this response as correct or helpful if it assisted you with your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-23-2018 07:03 PM
Can you share you server and client code?
Please mark this response as correct or helpful if it assisted you with your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-23-2018 07:07 PM
Sorry forgot to add my code.
My HTML Code is:
<div class="panel panel-default">
<div class="panel-heading">Case Action</div>
<div class="panel-body">
<button type="button" class="btn btn-primary btn-block" ng-click="c.uiAction('reapprove')">Re-Approve</button>
<!-- <button type="button" class="btn btn-default btn-block" ng-click="c.uiAction('cancel')">Cancel</button> -->
</div>
</div>
The Server Code is:
(function() {
gr = new GlideRecord('sn_hr_core_case');
if (input && input.action) {
var action = input.action;
if (action == 'reapprove') {
// Re-approve HR Case
gr.setValue('u_re_approve2', true);
gr.update();
}
//if (action == 'cancel') {
// // Do something else
// }
}
})();
The Client code is:
function() {
var c = this;
c.uiAction = function(action) {
c.data.action = action;
console.log(action);
c.server.update().then(function() {
c.data.action = undefined;
})
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-23-2018 07:20 PM
Try updating you script with below and check.
(function() {
gr = new GlideRecord('sn_hr_core_case');
gr.get(,$sp.getParameter('sys_id'));
if (input && input.action) {
var action = input.action;
if (action == 'reapprove') {
// Re-approve HR Case
gr.setValue('u_re_approve2', true);
gr.update();
}
//if (action == 'cancel') {
// // Do something else
// }
}
})();
Please mark this response as correct or helpful if it assisted you with your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-23-2018 08:55 PM
Hi Sanjiv,
Adding the additional line: gr.get($sp.getParameter('sys_id'));
(Although I did need to remove the comma you had entered before the $sp).
Thanks for your help - much appreciated!
Cheers Carl.