Hi,
We have in CS three separate Categories A, B, C for our both separated Support Teams A and B. Category B has 'Only Member has Access', and only Teams B User are the Member in this category; Category A has not this Limit. In the User role, the Teams A User can read/edit all requests, the Teams B User can only read/edit Requests in own Categories. If Teams B need 2-Level Supports from Teams A, he can change Ticket to Category C, it's the Under-Category of B and all User of Teams A and B are the Member of this Category. With this Configuration it works fine, both Teams get separated Visibilities and access to their Tickets in separated Categories and get common Access to the Tickets in Category C for 2nd-Level Support in our one Ticketsystem.
Now the Isses is, if Teams A User find that Ticket is not for his Teams and changed to Category B which he has not Visibility, it raised up an Error Message:
and it created a new empty Ticket, only filled Field are Ticket ID and created Time at current Time.
I asked our SO Local Suppprt Teams to check that Error Message and see more information:
An exception occurred in script: "Service: Saving a request: Message for closing Tickets" at: line 97, char 7
Original exception: DbODBC::FatalException at , line 97, char 7
An exception occurred in script: "Screen: Edit ticket 80 copy, Button: ok" at: line 138, char 16
Original exception: EjScript::RunTimeException
i have checked both Scripts. By crm-scripts for Trigger 'Saving a request', the error message was caused by t.save(). I know in this Trigger we don't need this code to save a Ticket, but without this, the set Value of user-defined Fields (UDF) will not be saved to the current Tickets.
By Scripts to OK-Button for Screen of Edit-Ticket, the Error Message was caused by red-arrow indicated code. I know all UDFs will be saved in default code:
But for some UDFs related to Tables i have set separated in the Screen, because I set special Simple Value to get limited Results of Output of the UDF related Tables.
That means, i need both codes in Scripts which caused the Error message. Now the question is, how could i optmize the Scripts to avoid this Issues with Error Message and new created empty tickets by User changed Ticket to Category with limited Access which he dos not have? The correct Output instead of that Error Message after this Changing should be for that User sth. like: You have no rights to access this Ticket.
Many thanks!
Alle Svar (8)
As soon as the category on the request is changed to one the user does not have access to, you will get this error. You can prevent the empty ticket being created by checking the return value of the .load method of the ticket class, if it returns false, it means you werent able to load the ticket, either because it doesn't exist or you dont have access to it.
You could try changing your code/.setValue to be above the code that changes the category? (or move the .setValue category to be below your code)
Hi David,
thanks for your Feedbacks. Yes, your 2nd part works, In the Scripts to OK-Button in Screen of Edit-Ticket, I put the setValue for changing Category below my code, the Issues with created empty Ticket is no more caused by this.
Just I don't understand very much your first part, where I can check and change the return-value of t..load Method in Scripts?
In Screenshots you see this in the Scripts for Trigger 'Saving a request' for my first cause of Issues.
Thanks a lot!
Hi David,
as you said, I checked the return-value of Ticket Load-Method in If-Condition to save the Ticket for my defined changed value of UDF, but it doesn't delivery me the results as i expected. The Issues with Error Message and empty Ticket disappered as expected, but the changed UDF-Value was not saved by this if-Condition.
Using Notify to send me Notification to watch the return-value of load-methode before and after t.save(), by changing Category to the one with limited Access which i don't have, before t.save() it returned me correctly false for loading that ticket, and after t.save() it didn't return me any value. By changing the Values of UDF only, it reurned me also correctly true.
Now the Problem is, the changed value of UDF what I implemented for t.save(), was not saved, in this case the Category was not changed. why the Logic was not runing in the if-condition? Also using the try/catch to save the ticket, didn't help, the changed UDF-value was not saved. Thanks a lot!
Hi david,
thanks for your indication, it works now.
But there is still a last little problem. if User change the Ticket to the limited Category and the fields in setValue in scripts changed together, the Issues with Error Message and empty Tickets raised up again. I cannot ask user pls. donot change both together...any Idea?
Thanks a lot!
You mean the User must manually split to save the ticket two times, once to save all other fields, once separated only to change to the limited Category? That's what i don't want.
If i split the t.save() in scripts in two times, both need to check the return-value of t.load again, the last litte problem cannot be prevented. or, do you have a short code sample?
Many Thanks!
No, i mean splitting the save action into two, something like this;
#setLanguageLevel 4;
Integer ticketId = 1;
Integer selectedTicketCategoryId = 2;
Ticket ticket;
if (ticket.load(ticketId) == false)
{
exitWithMessage("Unable to load ticket with id '" + ticketId.toString() + "', can't perform changes.");
}
Integer currentTicketCategoryId = ticket.getValue("category").toInteger();
// set custom and other fields here, don't change category field
ticket.setValue("x_", "value");
// save
ticket.save();
// category was changed, perform a seperate save
if (currentTicketCategoryId != selectedTicketCategoryId)
{
// load ticket again to make sure we have the latest values, since we did changes
if (ticket.load(ticketId) == false)
{
exitWithMessage("Unable to load ticket with id '" + ticketId.toString() + "', can't change category.");
}
ticket.setValue("category", selectedTicketCategoryId.toString());
ticket.save();
}
Hi David,
thanks very much for your code, i have implemented this in my Scripts.
But it didn't work if user changed the category to limited one and setValue together, i still got Error Message by our cust20815, just no more empy tickets created.
Checking your Code, i think, although it posted me exitWithMessage by loading Ticket = false at row 181, but the Logic go on runing to setValue till the Error Message posted me instead, I got the first exitWithMessage if i changed only the Category to limited one. And it has never chance to check the changed Category at row 201. Thanks a lot!
Good day Jianchun
in you code (line row 181) you have such code ->> if (!t.load(ticketId.toInteger()));
is the ! symbol really needed? since later you use t.save();