Required fields before closing ticket (CRMScript)

Hi

We have a customer that wants to make sure that a ticket has an owner and that there is at least one tag on the ticket, before being able to close the ticket.

Making a CRMScript to check these requirements on the "Changed status" trigger is easy enough. We could potentially make the trigger so that it simply sets the status back to the original status it was in, but I'm sure this will often go unnoticed by the user if they don't get some kind of warning saying "you need to set an owner/tag before closing the ticket".

It seems to me that the setValidationMessage() function doesn't do anything in Service, and I found an older post where this was confirmed. Does anyone know if there is a another way to do this or have any good ideas on how to solve this? And will the validation message function be available in Service one day?

Espen Steen
CRM Insight

RE: Required fields before closing ticket (CRMScript)

Hi! How about using the Notify and the notification bell to give the user a custom message that the ticket wasn't closed?

It's not really "in your face" the same way as a dialog but perhaps it could work?

 

Von: Thomas Akervall 4. Mai 2020

RE: Required fields before closing ticket (CRMScript)

Hi,

In Service you can close tickets in many different ways, so it is somewhat difficult to be able to catch all scenarios. 

Perhaps you can use Trigger on View request and display generic information message that it is not possible to close ticket without setting these values?

Von: Michel Krohn-Dale 4. Mai 2020

RE: Required fields before closing ticket (CRMScript)

Hi guys

Thomas: Thank you for the tip. I suspect it will not be "in your face" enough to be effective, but I will definitely look into it.

Michel: I'm not quite sure what you mean. Do you mean creating a message on the ticket that will be visible amongst the other messages (e-mails, comments)? If so I thought about that and it is an alternative, but it's not optimal. Or do you mean something else?

Espen

Von: Espen Steen 5. Mai 2020

RE: Required fields before closing ticket (CRMScript)

Hi,

I was thinking more like this with Trigger - View request screen - Loading

Giving a red error message on View request screen

Perhaps not 100% optimal but does alert user at least.

Von: Michel Krohn-Dale 5. Mai 2020

RE: Required fields before closing ticket (CRMScript)

Ah! This looks very interesting. I will look into this Michel, thank you!

Espen

Von: Espen Steen 5. Mai 2020

RE: Required fields before closing ticket (CRMScript)

This is definitely a way to do it, although preferably it would not be static.

So is there no way to pass information to the View Screen Trigger from another trigger? Something along the lines of: If status is set to Closed, the Changed Status Trigger sets a state value which is picked up in the View Screen Trigger and only then the Error message is displayed?

Espen

Von: Espen Steen 5. Mai 2020

RE: Required fields before closing ticket (CRMScript)

Hi Espen,

 

I would recommend the solution you suggested yourself:

Making a CRMScript to check these requirements on the "Changed status" trigger is easy enough. We could potentially make the trigger so that it simply sets the status back to the original status it was in, but I'm sure this will often go unnoticed by the user if they don't get some kind of warning saying "you need to set an owner/tag before closing the ticket".

 

Some input which may help:

Trigger used - Service: Request closed

#setLanguageLevel 3;
Integer ticketId = getVariable("ticketId").toInteger();
Ticket t;
t.load(ticketId);

// Check if ticket has an owner
String ticketOwner = t.getValue("ownedBy"); // where 1 = Unassigned/No owner

// Reopen ticket, add internal message to ticket
if (ticketOwner == "1") {
 t.setValue("ticketStatus", "1");
  // Add an internal message to the existing ticket
  Message mLog;
  mLog.setValue("ticketId", ticketId.toString());
  mLog.setValue("createdAt", getCurrentDateTime().toString());
  mLog.setValue("createdBy", getActiveUser().getValue("id"));
  mLog.setValue("type", "1");
  mLog.setValue("author", "System (script)");
  mLog.setValue("slevel", "1");
  mLog.setValue("body", "Your error message");
  mLog.save();
  t.save();
}

}

 

Make sure to add the tag-logic to this script as well and I would say this cannot be missed by a user, since the ticket will reopen and they should be eager to close tickets?? :)

Von: Bas Kreijveld 5. Mai 2020

RE: Required fields before closing ticket (CRMScript)

Hello Bas,

Yes, so far that is the best solution I have found. Again, it's not optimal though since the message might be considered clutter amongst the other messages. But it might be good enough.. Thank your for the help.

Espen

Von: Espen Steen 5. Mai 2020

RE: Required fields before closing ticket (CRMScript)

Hi,

These types of triggers(events and screens) are not connected, so I guess you would have to live with checking current values on ticket. If ticket does not have owner and is not closed -> show error message. By no means a perfect solution.

It would also make sense to perhaps add a message to ticket, and mark add important flag to it.
Snippet

#setLanguageLevel 3;
Integer ticketId = getVariable("ticketId").toInteger();
Ticket t;
t.load(ticketId);

String owner = t.getValue("ownedBy");

if (owner == "1") {
 t.setValue("ticketStatus", "1");

  Message message;
  message.setValue("ticketId", ticketId.toString());
  message.setValue("createdAt", getCurrentDateTime().toString());
  message.setValue("createdBy", getActiveUser().getValue("id"));
  message.setValue("type", "1");
  message.setValue("author", "System message");
  message.setValue("slevel", "1");
  message.setValue("body", "You must choose owner and Tag before closing ticket");
  message.setValue("important", "true");
  message.save();
  t.save();
}
Von: Michel Krohn-Dale 5. Mai 2020

RE: Required fields before closing ticket (CRMScript)

Hi

Just wanted to let you guys know how we solved this in the end. I think it works really well:

We made a boolean extra field called "x_triedclosed" on the ticket. A CRMScript on the "Changed status" trigger sets this field to 1 if the obligatory fields are not filled in on the ticket. 

Then, on the "View ticket" trigger, a SearchEngine checks if this value is 1, and if so displays the error message like Michel proposed:

The Changed status trigger of course also makes sure to set "x_triedClosed back to 0 if the ticket is closed with the obligatory fields, and also if you change the ticket to some other status (just to make sure that the error message is not displayed when it doesn't need to be).

Thanks for your help!

Espen

Von: Espen Steen 14. Mai 2020