Static transform VTL error

I am trying to simplify an expression that naively executes the same expression multiple times by leveraging the set directive, however the simplified expression fails to parse and I can’t figure out why.

Can anyone spot my issue between the first (failing) and second (working) examples below.

#set($managerParts = $managerDistinguishedName.split(",DC=", 2))
#set($employeeParts = $employeeDistinguishedName.split(",DC=", 2))
#set($managerDomain = $managerParts.size() > 1 ? $managerParts[1] : "")
#set($employeeDomain = $employeeParts.size() > 1 ? $employeeParts[1] : "")
#if($managerDomain.equals($employeeDomain))
$managerDistinguishedName
#{else}
#end
#if($managerDistinguishedName.split(",DC=",2).size() > 1 && $employeeDistinguishedName.split(",DC=",2).size() > 1 && $managerDistinguishedName.split(",DC=",2)[1].equals($employeeDistinguishedName.split(",DC=",2)[1]))
$managerDistinguishedName
#{else}
#end

The $managerDistinguishedName and $employeeDistinguishedName are populated with the related data using existing transforms in the static transform.

I have escaped the double quotes and merged the expressions into a single line, and also replaced the escaped double quotes with single quotes with no luck.

Maybe that equals doesn’t like a null that it is seeing or something. Maybe try == instead?

1 Like

Hi,
It was the ternary that got it bent out of shape.

To be honest, the programmatically “correct” way of doing this is significantly longer than evaluating the string operation twice, i’ll just leave it…

Thanks for the suggestion!

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.