How to print "Not set" when there is no value assigned for DNG custom attribute in RPE template?
I am retrieving custom attribute value from DNG into RPE template by using query (dataSource/artifact/collaboration/attributes/objectType/customAttribute/name ) and (dataSource/artifact/collaboration/attributes/objectType/customAttribute/value) which is working fine when the value is true/false.
Now I want to add a condition to print "Not set" when there is no value assigned for that custom attribute. I have tried several things as below,
1.
if(value != "") {
attribute_value = value
}
else
attribute_value = "Not Set"
}
2. provided condition in a container (value == "No value"), print "Not Set" in the text element.
But it is not printing "Not set" in case of no content.
Can anybody please help on this?
Accepted answer
If you were to view the actual data returned from the DNG server for your data source, my guess is that it's not returning any information at all for the custom attributes that aren't set. If there's no data there, then the customAttribute query doesn't have anything to look at, and your code doesn't execute.
Try initializing your "attribute_value" variable to "Not Set" before you go into the customAttribute query.
One other answer
Hi Anjuri,
is it a boolean attribute?
You could try first assigning the value of the boolean attribute to a string variable.
Then query the value of the string variable instead of querying the value of the attribute.
It should be either 'True', 'False' or blank.
If it is blank then assign the value "Not Set'
Then publish the variable instead of publishing the attribute value.
Comments
Hello Sean,
Thank you so much for your response. Yes, it is a Boolean attribute. I tried initializing variable same as mentioned in https://jazz.net/forum/questions/253483/rpe-dng-how-can-i-access-an-empty-attribute-and-replace-it-with- and it started publishing "Not set" when the value is blank.
Thanks!