Prevent incidents being resolved while logged as Guest

lynchr02
Tera Contributor

We have loads of email release incident tickets come into us from shared mailboxes which then get logged under the Guest caller. A lot of these tickets are getting closed under Guest which from a reporting point of view is not good. Would anyone have any idea for code for a client script to prevent incident records being set to resolved if the Caller field is still Guest? This is what I have so far 5136503cc611227c0183e96598c4f706 is the sys ID for our Guest account

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var caller_name = g_form.getValue(‘caller_id’);
if(caller_name == ‘5136503cc611227c0183e96598c4f706’){
g_form.setValue(‘state’, ” ”);
g_form.addInfoMessage(“An incident can not be resolved while Caller is set to Guest. Please get the original requestor's name”);
//}
//}
//Type appropriate comment here, and begin script below

}

2 ACCEPTED SOLUTIONS

Robbie
Kilo Patron
Kilo Patron

Hi @lynchr02,

 

Whilst a Client Script or UI Policy will certainly help with the User Experience (UX), it's best to trap this at the server layer.

You may also want to consider not just Resolution, but also closure. See the below Business Rule to implement to take care of this for you.

 

To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Kudos.



Thanks, Robbie

 

Screenshot 2024-08-08 at 09.42.33.pngScreenshot 2024-08-08 at 09.42.42.png

 

(function executeRule(current, previous /*null when async*/ ) {

    gs.addInfoMessage("An incident can not be resolved while Caller is set to Guest. Please get the original requestor's name");
	current.setAbortAction(true);

})(current, previous);

View solution in original post

Great - No worries at all @lynchr02. Happy Thursday ; )

 

To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Kudos.



Thanks, Robbie

View solution in original post

8 REPLIES 8

Ehab Pilloor
Mega Sage

Hi @lynchr02,

You can use write ACL for this too.

However if you want to restrict it for Guest without ACL, I suggest you use UI Policy and make the fields read only for Guest. U can use scripting there and check if logged in user is Guest and then the UI Policy would apply. This would be applicable if you want to restrict Guest from editing many fields.

If only few fields should be made read only then make he following changes:

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var caller_name = g_form.getValue(‘caller_id’);
if(caller_name == ‘5136503cc611227c0183e96598c4f706’){
g_form.setReadOnly(‘state’, false);
g_form.addInfoMessage(“An incident can not be resolved while Caller is set to Guest. Please get the original requestor's name”);
//}
//}
//Type appropriate comment here, and begin script below

}

If you found my reply useful, please mark it as Solution and Helpful.

 

Thanks and Regards,

Ehab

 

 

 

Amit Pandey
Kilo Sage

Hi @lynchr02 

 

You can create a before update business rule like this-

 

AmitPandey_1-1723105323982.png

 

(function executeRule(current, previous /*null when async*/) {
    
    var guestSysId = '5136503cc611227c0183e96598c4f706';
  
    if (current.caller_id == guestSysId) {
        gs.addErrorMessage('Guest tickets cannot be resolved.');
        current.setAbortAction(true);
    }
})(current, previous);

 

Please mark my answer helpful and correct.

 

Regards.

Amit

 

 

Robbie
Kilo Patron
Kilo Patron

Hi @lynchr02,

 

Whilst a Client Script or UI Policy will certainly help with the User Experience (UX), it's best to trap this at the server layer.

You may also want to consider not just Resolution, but also closure. See the below Business Rule to implement to take care of this for you.

 

To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Kudos.



Thanks, Robbie

 

Screenshot 2024-08-08 at 09.42.33.pngScreenshot 2024-08-08 at 09.42.42.png

 

(function executeRule(current, previous /*null when async*/ ) {

    gs.addInfoMessage("An incident can not be resolved while Caller is set to Guest. Please get the original requestor's name");
	current.setAbortAction(true);

})(current, previous);

lynchr02
Tera Contributor

Thanks Robbie for some reason when I go into Business Rules and create a new one when the page renders the condition options disappear as well as the Advanced tab so I can't enter the script code you provided. It happens in both Chrome and Edge any ideas?