I am experimenting with taking an ISO style date (2024-05-14) that’s being added as a custom field value (from a custom web form that’s emailed in to RT - I already got the front-end working and RT to extract the custom field and put it into a ticket CF by way of a batch scrip “On Create” that extracts the CF from a SMTP header from my web form and successfully adds into a CF).
Then I have a new scrip I’m playing with that I can’t get to work… I’ve tried it as a normal and a batch scrip, but I think since the CF is being populated from a previous batch scrip on create, the next scrip will have to be batch also.
The new scrip is also a batch scrip:
Condition “User Defined”
Action: “User Defined”
Custom condition -
return 0 unless $self->TransactionObj->Type eq “Create”;
return 0 unless $self ->TicketObj->Subject =~ /New Hire/ ;
return 1;
Custom action preparation code:
return 1;
Custom action commit code (I’ve tried (3) different action commit code’s):
Try1 -
my $ticket = $self->TicketObj;
my $CFName = “Start Date”;
my $QueueObj = $self->TicketObj->QueueObj;
my $CFObj = RT::CustomField->new ($QueueObj->CurrentUser);
$CFObj->LoadByNameAndQueue(Name=>$CFName, Queue=>$QueueObj->id);
startdate = $self->TicketObj->FirstCustomFieldValue($CFObj->id);
$self->TicketObj->SetDue($startdate->ISO);
Try2 -
my $ticket = $self->TicketObj;
my $CFName = “Start Date”;
my $QueueObj = $self->TicketObj->QueueObj;
my $CFObj = RT::CustomField->new ($QueueObj->CurrentUser);
$CFObj->LoadByNameAndQueue(Name=>$CFName, Queue=>$QueueObj->id);
my $Due = new RT::Date($RT::SystemUser);
$Due = $self->TicketObj->FirstCustomFieldValue($CFObj->id);
$Due->AddDays(1);
$self->TicketObj->SetDue($Due->ISO);
Try3 -
my $ticket = $self->TicketObj;
my $CFName = “Start Date”;
my $QueueObj = $self->TicketObj->QueueObj;
my $CFObj = RT::CustomField->new ($QueueObj->CurrentUser);
$CFObj->LoadByNameAndQueue(Name=>$CFName, Queue=>$QueueObj->id);
my $startdate = $self->TicketObj->FirstCustomFieldValue($CFObj->id);
$self->TicketObj->SetDue($startdate->ISO);
Any chance anyone can give the above a quick once-over? I feel like I’m missing something really obvious here…