Skip to main content
Solved

Using @CurrentAttribute in condition definition


albinepro
Supporter
Forum|alt.badge.img+7

I have encountered a problem when formating a datetime. A log is raising a warning when the value is null. In order to avoid warnings in log I try to setup a condition in AttributeManager. I would like to reuse (copy/paste) the condition definition so I try to use "@CurrentAttribute". It's working as expected in Attribute Value part, but not in the test condition (see attached image).

If I use 

@CurrentAttribute() ATTRIBUTE_HAS_A_VALUE

I get <null> results despite the attribute has a value. Any suggestion how to set up the condition for current attribute correctly?

 

current_att

Best answer by ebygomm

albinepro wrote:

Understood, thanks. Is there a function then that would return a current attribute name in order to use with ATTRIBUTE_HAS_A_VALUE?

No, ATTRIBUTE_HAS_A_VALUE seems to work slightly differently. This sort of setup works for me

image

View original
Did this help you find an answer to your question?

Forum|alt.badge.img+2

@albinepro​ Do you have a small example workspace you can share with the configuration you're trying?


albinepro
Supporter
Forum|alt.badge.img+7
  • Supporter
  • February 16, 2023
markatsafe wrote:

@albinepro​ Do you have a small example workspace you can share with the configuration you're trying?

@Mark Stoakes​ I have uploaded a sample workspace in the original question. There are 4 datetime manipulations in the AttributeManager, the last one "datum_uzavreni" is setup to @CurrentAtrribute adn outputs just nulls. If I setup it to the exact attribute as the rest of the conditions, it works as expected. Maybe I am missing something. thx


Forum|alt.badge.img+2
albinepro wrote:

@Mark Stoakes​ I have uploaded a sample workspace in the original question. There are 4 datetime manipulations in the AttributeManager, the last one "datum_uzavreni" is setup to @CurrentAtrribute adn outputs just nulls. If I setup it to the exact attribute as the rest of the conditions, it works as expected. Maybe I am missing something. thx

@albinepro​ Thanks very much for the example. This would be a good use o @CurrentAttribute() . In it's current for, it won't work for this use case, but I'll see if we can change that.

Perhaps you could use DateTimeConverter to avoid the messages


Forum|alt.badge.img+2

@albinepro​ The reason this doesn't work as you'd like is because @CurrentAttribute() returns the value of the current attribute not the attribute name.  So if, say, the current attribute has a value of 123, then the condition @CurrentAttribute() ATTRIBUTE_HAS_A_VALUE will end up checking whether an attribute named 123 has a value.


albinepro
Supporter
Forum|alt.badge.img+7
  • Supporter
  • March 20, 2023
markatsafe wrote:

@albinepro​ The reason this doesn't work as you'd like is because @CurrentAttribute() returns the value of the current attribute not the attribute name.  So if, say, the current attribute has a value of 123, then the condition @CurrentAttribute() ATTRIBUTE_HAS_A_VALUE will end up checking whether an attribute named 123 has a value.

Understood, thanks. Is there a function then that would return a current attribute name in order to use with ATTRIBUTE_HAS_A_VALUE?


Forum|alt.badge.img+2
albinepro wrote:

Understood, thanks. Is there a function then that would return a current attribute name in order to use with ATTRIBUTE_HAS_A_VALUE?

@albinepro​ Sorry, not that I can think of.


ebygomm
Influencer
Forum|alt.badge.img+32
  • Influencer
  • March 30, 2023
albinepro wrote:

Understood, thanks. Is there a function then that would return a current attribute name in order to use with ATTRIBUTE_HAS_A_VALUE?

For this particular case you could test if CurrentAttribute length was greater than 0 and only attempt the date formatting if that was the case


albinepro
Supporter
Forum|alt.badge.img+7
  • Supporter
  • March 30, 2023
albinepro wrote:

Understood, thanks. Is there a function then that would return a current attribute name in order to use with ATTRIBUTE_HAS_A_VALUE?

It would be the same as checking if ATTRIBUTE_HAS_A_VALUE. I just needed a generic statement to copy/paste the condition of an attribute. If Im checking length, I still need to define the name of attribute Im checking.


ebygomm
Influencer
Forum|alt.badge.img+32
  • Influencer
  • March 30, 2023
albinepro wrote:

Understood, thanks. Is there a function then that would return a current attribute name in order to use with ATTRIBUTE_HAS_A_VALUE?

No, ATTRIBUTE_HAS_A_VALUE seems to work slightly differently. This sort of setup works for me

image


albinepro
Supporter
Forum|alt.badge.img+7
  • Supporter
  • March 30, 2023
albinepro wrote:

Understood, thanks. Is there a function then that would return a current attribute name in order to use with ATTRIBUTE_HAS_A_VALUE?

Ok, that could work if it doesn't actually need attribute name.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings