It's all about the answers!

Ask a question

How to print "Not set" when there is no value assigned for DNG custom attribute in RPE template?


Anjuri Kelaiya (253) | asked Oct 10, 6:44 a.m.

 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


permanent link
John Pawasauskas (511) | answered Oct 10, 11:27 a.m.

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.


Anjuri Kelaiya selected this answer as the correct answer

Comments
Anjuri Kelaiya commented Oct 13, 2:24 p.m.

Thanks for your response John.


I tried initializing "attribute_value" to "Not Set" and set the queries, tried different variations but still no luck.

One other answer



permanent link
Sean F (74212232) | answered Oct 14, 8:52 a.m.
edited Oct 14, 8:53 a.m.
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
Anjuri Kelaiya commented Oct 15, 1:59 a.m.

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!

Your answer


Register or to post your answer.