
- 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 12:13 PM
Ok...I would suggest use the UI action. That is much more easy, since you just want to set a field and not perform any client action. Create a UI action on you table and add your script instead of modifying the widget
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:36 PM
OK that sounds good - just not sure how I would be able to add a UI Action to my portal page and have it accessible form the hrj ticket page.
Are you able to help with this?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2018 01:22 PM
When you add a UI action on the table, it should automatically appear on the form.
I dont have access to that page right now, since I dont have HR plugin activated.
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 02:34 PM
A UI Action only works that way on the client side of ServiceNow, I need this to work on the portal, so it's definitely a widget mod that is required...

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2018 03:17 PM
A UI action also works on portal. Because I have created myself lot of Server UI action which works fine on Portals.
But Since I am not sure what are you displaying on the portal, I would ask you to try both. If it is a form widget, it should ideally show all the UI actions as well
Please mark this response as correct or helpful if it assisted you with your question.