Skip to main content
Solved

Using @CurrentAttribute in condition definition

  • February 15, 2023
  • 10 replies
  • 354 views

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

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

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

10 replies

Forum|alt.badge.img+2
  • 1891 replies
  • February 15, 2023

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


albinepro
Supporter
Forum|alt.badge.img+7
  • Author
  • Supporter
  • 31 replies
  • February 16, 2023

@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
  • 1891 replies
  • February 17, 2023

@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
  • 1891 replies
  • February 21, 2023

@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
  • Author
  • Supporter
  • 31 replies
  • March 20, 2023

@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
  • 1891 replies
  • March 22, 2023

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+44
  • Influencer
  • 3422 replies
  • March 30, 2023

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
  • Author
  • Supporter
  • 31 replies
  • March 30, 2023

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+44
  • Influencer
  • 3422 replies
  • Best Answer
  • March 30, 2023

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
  • Author
  • Supporter
  • 31 replies
  • March 30, 2023

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.