Bokkie
Bokkie

Reputation: 13

Freemarker/Topdesk conditional content

I am trying to alter a step in one of our automated actions with freemarker, as the error is caused by a null value, which may be expected.

The execution log in Topdesk shows the following:

Error while processing FreeMarker template: The following has evaluated to null or missing: ==> _responses.get_ticket_info.body.object [in template "action" at line 1, column 82]

[...] Tip: If the failing expression is known to legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??

The full URL is as follows: ${_variables.topdesk_url?no_esc}/tas/api/assetmgmt/assets?$filter=name%20eq%20'${_responses.get_ticket_info.body.object.name}'

I am not sure about the proper syntax/values...

As my conditional I currently have <#if ${_variables.topdesk_url?no_esc}/tas/api/assetmgmt/assets?$filter=name%20eq%20'${_responses.get_ticket_info.body.object.name}'??>true<#else>false</#if>

although I guess, since it's saying the first one only covers the last part of the expression, I only need to put <#if ${_responses.get_ticket_info.body.object.name}??>true<#else>false</#if>

I have not created a variable in the first step. the first step's result (_responses.get_ticket_info.body) contains a the variable object, which has a variable name which in this case has the value "null".

So I would like to skip step 2, and consequently every following step, instead of step 2 causing an error and every following step being skipped.

Can you please help remove my doubt?

Upvotes: 0

Views: 231

Answers (1)

ddekany
ddekany

Reputation: 31162

You could use <#if _responses.get_ticket_info.body.object??>, as the error message suggests too.

Upvotes: 0

Related Questions