- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2016 08:51 PM
Helsinki Service Portal does not support Client marked UI Actions. We have UI Actions on Incident form on click of which certain fields should turn mandatory on form and check for data. If the data is filled, then go ahead with server action. We are displaying incidents on Service Portal in Form Widget. How do we replicate this behavior when working on Incident records in Service Portal Form Widget?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2016 07:27 PM
HI Hardik,
Honestly at the time of my reply I did not thought about that point. But I did a quick search in the documentation and it is actually pretty simple, you can use: g_form.getActionName(), which will return your UI Action name so you can make a condition based on that name.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2017 04:26 AM
First you should make sure that your client script UI Type is set to both.
Here is an example of a script working in both UI:
function onSubmit() {
//Type appropriate comment here, and begin script below
if(g_form.getActionName() == 'test_update'){
return confirm('Do you confirm?');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2017 05:21 AM
Thanks Laurent for quick reply! Issue is with my client script UI Type which is not set to both.
Thanks for your assistance!
Can you help me on other thing?
UI Action is "Delete" which is visible on service portal form. If we click on "Delete", current record will be deleted (after confirmation) and should redirect to previous page in service portal or list page in service portal.
Could you please help me how can we set redirection in UI Action (which works in service portal form)? or any other way to handle this scenario (after deleting record, redirection should be to previous page or some desired list page in service portal)?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2017 04:58 AM
Hi Pavan,
To do this, you will have to modify the form widget (clone it and modify), then you place the cloned widget on your form page to replace the OOTB one. As action.setRedirectURL does not work in service portal, it is the only option that I'm aware.
To do it you will need to modify 2 functions of the client controller:
$scope.triggerUIAction = function(action) {
if ($scope.data.disableUIActions)
return;
if (g_form) {
$timeout(function() {
if(action.action_name == 'sysverb_delete'){
$scope.isDelete = true;
}
g_form.submit(action.action_name || action.sys_id);
});
}
}
The modification is to check for the action_name sysverb_delete, you can set another name if you used a differennt name. If it is your delete we set that value in the $scope for later use.
$scope.$on("spModel.uiActionComplete", function(evt, response) {
if($scope.isDelete){
$location.url($location.path()); // Reset the url parameters
$location.search('id', 'list');
$location.search('table', $scope.data.f.table);
}
else{
var sysID = (response.isInsert) ? response.sys_id : $scope.data.sys_id;
loadForm($scope.data.table, sysID).then(constructResponseHandler(response));
}
});
The modification is that we check if the action executed was delete and if it was, we rediect the user to the list view of the current table. You might want to add additionnal parameters for the query of the list. Otherwise the original script is runned.
If you wanted to redirect to the previous page instead of the 3 $location line, you would use: $window.history.back();