
- 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-22-2018 10:34 PM
In the server code where is grCase is defined.
Also add some debug statements to check if your code is entering the function
function(){
// Send for Re-Approval
if (input && input.action){
var action = input.action;
gs.addInfoMessge('++++action is +++++'+action);
if (action == 'reapprove'){
grCase.setValue('u_re_approve2', true);
grCase.update();
}
}
}
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-22-2018 10:42 PM
Thanks for your reply Sanjiv - I have added that line and am not seeing anything in my browser - where would this show up if it was being called (just to check I'm not missing it by looking in the wrong place).

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2018 09:15 AM
Is that the whole server script? If yes, you are missing lot of lines in there.
That debug message should appear on top.
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 12:01 PM
The entire script is large is it is provided with 'hrj-case-info' widget. The section of code I have shown is the new code added only for the new button.
I added your debug line in another place in the existing server script and I received a number of red line errors, so i know this is being called in that place, but when I add it to my function the errors don't show, so i can safely assume my server function isn't being called from the client.