- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2015 09:04 PM
Hello All,
we have a scenario where user should not be able to close requested item until and unless all the tasks related to that requested item are closed,
for the same there is a before update business rule as below.
var rec = new GlideRecord('sc_task');
rec.addQuery('request_item',current.sys_id);
rec.addQuery('state','!=',3);
rec.query();
if(rec.next())
{
gs.addErrorMessage('Please close all the tasks before closing the requested item');
current.setAbortAction(true);
There is client script when status is closed all the fields will be made read only.
So the issue here is when user changes the status to close in requested item and updates it , it gives invalid update based on the above BR, and all the fields are greyed out because of the client script,
But actually the transaction is not complete (i.e. the requested item is still open), which user comes to know when he reloads or refresh the form which is actually mis-leading.
please let me know what are the modifications to be done.
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2015 10:47 PM
It seems like setAbortAction is not working . Following thread may help you a little
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2015 09:19 PM
I believe that you are using a onChange client script on state field , use onload Client Script instead to make fields readonly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2015 09:29 PM
I changed it to Onload but that didn't help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2015 09:36 PM
Look .. if you moved the code to onLoad then fields will not become readOnly after changing the state but they will become readOnly after you save those changes and page is reloaded. Now , at onLoad if the update operation was successful then only the state will be closed and thus all fields will be readOnly else not.
Can you share the code of onLoad Script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2015 10:27 PM
The code onLoad looks like this.
function onLoad() {
//Type appropriate comment here, and begin script below
if(g_form.getValue('state') == 3)
{
var fields = g_form.getEditableFields();
for (var x = 0; x < fields.length; x++)
{
g_form.setReadOnly(fields[x],true);
}
}
}