Saving a request vs. Request changed status Trigger

Hi,

I have been trying to do a script that sends a reply template if Status is changed, to me this make sence using Trigger - Request Changed status but when I use 

 

if ((getParserVariable("ticket.new.ticketStatus").toInteger() == 2) && (getParserVariable("ticket.old.ticketStatus").toInteger() == 7))
{

// Do things

}

ticket.new.ticketStatus and ticket.old.ticketStatus will be empty when I trace the script.

If I try this under Saving a request they do contain values.

What is the differences between the triggers and what you can access, how can I easily see what values I can use?

 

Apprecieate an explanation or link where I can read up on this.

Thanks!

RE: Saving a request vs. Request changed status Trigger

Hi

Nature of these events are different, so variables accessible in each of them are not identical.

You can find some information about variables available in this event in TriggerScripts part of SDK.

By: Michel Krohn-Dale 11 Mar 2021

RE: Saving a request vs. Request changed status Trigger

So I had a look at ticketStatus.new|old for TicketChangedTicketStatus and on my test request I get values 10 and 11 that is not documented?

 

I guess I can use Saving a request trigger for this also but thought changed status Trigger had been the more logical way since I want it to happen when status changes.

By: Johan Friberg 11 Mar 2021

RE: Saving a request vs. Request changed status Trigger

Hi Johan,

Personally I really like to do the following:

1) Create a trigger (script) > select the trigger type

2) Add the following code and enable a trace

 

Map mVar = getVariables();
while(!mVar.eof())
{
print("Var: " + mVar.getKey() + ": " + mVar.getVal() + "\r\n");
mVar.next();
}

 

3) Apply the trigger and evaluate the trace >> available options for that specific trace (and results) are shown accordingly.

By: Bas Kreijveld 11 Mar 2021

RE: Saving a request vs. Request changed status Trigger

Hi,

I would guess that you also have some userdefined statuses in your solution, the ids of these will be difficult to document.
It is also possible to use this code together with tracing to see which variables you have access to;

EventData ed = getEventData();
String tmp = ed.getInputValues().toJson();
By: Michel Krohn-Dale 11 Mar 2021

RE: Saving a request vs. Request changed status Trigger

Thank you Bas and Michel for your inputs, very helpful!

By: Johan Friberg 12 Mar 2021