- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 12-04-2017 03:18 AM
We have been working on a way to add a Resolve Incident button in the mobile app. Our users can't set state "Resolved" through the state picker and UI Policys doesn't really work in our environment when it comes to this.
There was also a problem that the Resolve Incident button would resolve the incident without checking for conditions properly beforehand (it did after, but that's a bit late).
Short description on how I solved this
Since the mobile app is limited in making checks and changes using GlideForm I found my below method to work the most satisfactory.
UI Action
First, a mobile UI Action (go to the module UI Actions - Mobile) with the following settings.
As you can see, the name and action_name are placeholders, pick better ones for live version.
The condition checks that the incident is not resolved and that assigned to is the user of the phone. Still not perfect, pick better ones for live version.
And code:
if (typeof window == 'undefined'){
serverResolve();
}
function serverResolve(){
var resolveThis = new mobileResolveIncident(current);
}
I'm using the old client script code to call a function. The function in turn calls a script include with "current".
Script Include
And here is the script include:
As is visible, this is just a proof of concept on my part. As open as possible to everything to find it works.
And the code is very simple, I need it to not have any hidden features or issues at the moment.
function mobileResolveIncident(current) {
if(current.comments != '' && current.assigned_to != '')
{
current.state = '6';
current.incident_state = '6';
current.update();
gs.setRedirect('incident_list.do');
}
else {
errorMsg();
}
}
function errorMsg(){
gs.addErrorMessage('Add comments when resolving');
}
A check is made that additional comments has been added and that the incident is assigned to someone.
If these conditions are fulfilled, it will set state to resolved, update the incident and send the end user to the incident list.
If the conditions are not fulfilled, it runs a function within the script include (of course not necessary, just for testing purposes) that adds an error message to the user. And the incident will not have it's state changed.
Issues we still have
We haven't solved to make Additional Comments mandatory. It works using client script, but then the error message won't show. We know this from having first tested using a business rule that checked for incident to change to resolve, that in turn stopped the action. In addition to the business rule there was a client script that on submit of empty additional comment made this mandatory. And lastly there was the button which set resolved all on its own.
The script include and error message is a better fit for us, but if asked I can provide how far we got on the other attempt.
We also need to fix a few beauty issues with conditions, information etc. Perhaps get the client script to work somehow, but that seems hard as the ui action won't accept additional commands outside the server-call.
- 2,745 Views
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
This functionality worked well... thanks for the code! Just one question, I am also trying to unhide fields when the resolve is clicked ... Any ideas, as UI Policies don't seem to be working as expected. Thanks!