[Request Tracker - Incident Response] Trying to implement NCISS for IR in Request tracker

Hello people,

I was trying to implement NCISS scoring in RTIR.

I have created all the custom fields that is required with combo box.

Now i have to work on the scrip.

The condition is “On Create” so when user selects the values for the custom fields and click create button, the scrip will trigger.

Now for action, i have to write a perl code which gets the values from each custom field, performs some calculations and then create a new custom field and load this final score to the new custom field.

I’m not comfortable with perl and not sure how do i access the custom field value via perl.

Can anyone help me with this?

Please respond if you have an idea. any help would be appreciated.

Thank you,

Nishanth Shenoy

If I am following correctly, you want to do the following:

  1. Create a new ticket with some custom field values
  2. On create run a scrip that checks these custom field values then sets a new values for some final score custom field?

Thanks for response knation.

I have already created custom fields (combo box) and applied to the queue.

I want to get the value from each of the combo box, then using if else statements i will assign the score for each category and finally do some calculations and set another custom field with this final score.

I am able to get the custom field value using
my $cf1 = $self->TicketObj->FirstCustomFieldValue(‘field name’);

but when i use $cf1 to compare with string, that action is not happening correctly.

Any suggestions?

What about it is incorrect? Maybe share some code snippets?

here you go. This is a simple code snippet.

my $cf6 = $self->TicketObj->FirstCustomFieldValue(‘Recoverability’);
my $final = ‘’
if ($cf6 eq ‘Regular’) {
my $final = ‘changeme’;
}

$self->TicketObj->AddCustomFieldValue(Field => ‘NCISS Score’, Value => $final, RecordTransaction => 1);

the flow does not enter the if loop even if i select Regular in the combo box.

You are missing a ; after my $final = ‘’

Yea fixed that, but not working. :frowning:

Its compiling correctly, but the custom field is not getting updated.

You can do this:

my ($ret, $msg) = $self->TicketObj->AddCustomFieldValue(Field => ‘NCISS Score’, Value => $final, RecordTransaction => 1);
RT::Logger->error("Could not set custom field value: $msg") unless $ret;

This will log if RT is encountering an error when setting this value

Where can i find the logs?

If you did not set them in config then they will be in your web server logs, usually apache

can see couple of interesting things:

[warning]: “my” variable $final masks earlier declaration in same statement at (eval 1560) line 4, line 269. ((eval 1560):1234:

[warning]: Use of uninitialized value $_[2] in join or string at (eval 829) line 2. ((eval 829):2)

Does it help?

But could not see anything with “Could not set custom field value” in apache error logs

You are defining the variable ‘$final’ twice, you can get rid of the my in front of the second $final

1 Like

Awesome this worked and if loop executed. i"ll apply the real logic now and see if everything works fine.
It involves integers. So should i type cast them as integer.

I was able to implement what i needed.

Thanks a lot for the help @knation

1 Like

You can find a lot off examples here:

https://rt-wiki.bestpractical.com/wiki/CustomConditionSnippets