what i noticed is this. If go to the ticket and then to Actions (top menu, the last option) and when dropdown opens you select resolved (or comment,…).
And then you add comment, add right CF and you do update of the ticket. Then this values are not send via api.
You might want to look at the LoadCustomFieldByIdentifier() in RT::Ticket as that is overloaded to look at queue specific custom fields before global ones.
@craig . I need to send status of the ticket, and need to send all my CFs and the comment/content of the ticket via API (json). If the CF are set before I go to Actions->Resolved that I will get them via API (only comment is missing).
If I will do status change again, I will get this values. If the values are changed with status, I will get old values but not the new ones.
@GreenJimll
Like this i guess. But I get hash, i tried with dump hash but I do not see any useful data.
RT::Logger->error(“Testing RC”, $self->TicketObj->LoadCustomFieldByIdentifier(“ResolutionCategory”));
@GreenJimll I not it is noob question but I am so new to perl.
Ok I get an object.
$CFrc1=$self->TicketObj->LoadCustomFieldByIdentifier(“ResolutionCategory”)
Which method I need now to use to get values. Or in easier way, how to use the right method to get data?
also what about comment, which is also not displayed?
When you get ‘undef’ for the custom field values does the ticket have a value for these fields already and they are not showing up? Or are the field values being set on the action that you are performing (IE the values are being set but not set while the scrip runs)?
Going back to the “what the scrip should do” how accurate is this “On ticket comment or reply send the comment and some other relevant fields to some external API”?
@Craig, the second thing. The field values are being set on the action that I am preforming (The values are set as I can see them but the script does see them).
if I set status again (different) and also change CF I can see old CF, but not new ones.
For exp now i changed status and add CF:
Ticket 219: Status changed from ‘open’ to ‘resolved’
Since RT scrips run per transaction it seems that status gets set before the custom field values, meaning if you run this code then you will see old values for custom fields.
It may be better to use a callback from the ticket display page and in that callback get the Ticket object and send the values of the object to your API.
You can use the ‘BeforeDisplay’ callback from Ticket/Display.html you will need a method for checking that an update occurred (Maybe check if the @Actions array has any values) and if so then you can send the data to your API.
@Jeff_Voskamp2 and @craig thank you! As I selected to run script as batch the script started to work properly.
Now when I select script an select from normal to bacth, when I can see that this script runs as batch :)?
Just to know how to find out in future in which stage some script belongs to