I have a Source and Target 'applicant component' connected with an 'association' relation. Target application component as a property Status = live
I want to display on the Source as a label the Target's status property if it exists.
I can do on the Source element in the Label and will display the Targets property Status value:
$association:target{property:Status}
Now, I want to build this into a conditional statement so it shows the property value if present, otherwise show the text "Empty", however this does not work instead showing the expression as text in the Source element:
${if:<place the above here>:<place the above here>:Empty}
i.e.
${if:$association:target{property:Status}:$association:target{property:Status}:Empty}
What is observed is the Label expression is displayed with the property value shown i.e.
The Source element shows the text:
${if:Live:Live:Empty}
Can someone please let me know what I am doing wrong - thank you
Hi, please try this:
${nvl:$association:target{property:Status}:Empty}
That translates to "If there is a property with name "Status" in the first target of the association relationship, display the property's value, else display "Empty"
Hi Phil,
Yes, I figured out the problem...
The issue is that the value of the Status property for one of the Target element has the ':' char so when this is evaluated it forms part of the label expression causing a syntax error resulting in the whole expression seen as text which it displays.
When I changed to the property value to exclude ':' character it worked as expected.
Is there a way to correct the expression so it will work for values that include ':'?
Property: Status = 'Legacy: Replace'
${nvl:$association:target{property:Status}:Empty}
Results in the display of:
${nvl:Legacy: Replace:Empty}
Changing the property value to remove the ':', i.e. 'Legacy Replace'
It displays correctly in the element: Legacy Replace
Quote from: Manj75 on January 24, 2024, 17:13:53 PMThe issue is that the value of the Status property for one of the Target element has the ':' char so when this is evaluated it forms part of the label expression causing a syntax error resulting in the whole expression seen as text which it displays.
When I changed to the property value to exclude ':' character it worked as expected.
Is there a way to correct the expression so it will work for values that include ':'?
Sorry, no. It seems this is a side effect / bug of the algorithm to parse label expressions.
Ok - I'll replace all usage of the ':'
Thanks for your quick assistance.
Actually, you can escape the ":" with a backslash like this - "\:". However, this means changing the property value which means that backslash will show wherever you view the property value.