Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

How to check attribute's behaviour (mandatory or not mandatory).

Hi,
    Based on attribute behavior i.e., if an attribute is mandatory, I have to do some operation. This is mainly using Javascript(Dojo). It is equivalent to reading a workitem's attribute behavior.


getValue: function(attribute, workItem, configuration) {

 // using workItem.getX() or configuration.getX(), can we read the attribute behavior.
}



Is there a way to achieve this using Javascript (Attribute Customization - Scripts based value). Or we have to use API Extension. Kindly guide me on this.

Thanks.

0 votes


Accepted answer

Permanent link

An attribute can be read-only based on the values of other attributes during the save, so I doubt that you can determine whether it is read-only when in the editor.

Ralph Schoon selected this answer as the correct answer

0 votes

Comments

Hi,
   I doubt that the above explanation is not helping me. It is in javascript like getting an attribute value, is there a way to get the attribute behavior (ex. mandatory or not mandatory).

I got this workItem.isAttributeSet(). Which gives a boolean value, where an attribute contains a value or not. Similar to this, I need to check isAttributeMandatory(), this is not a real function. But I am showing it as an example.

You completely missed the point. An attribute can be deemed as read-only after you submit the data to the server. If the server detects that you are trying to modify such an attribute, it will refuse and return an error. There is no simple way you can find this out beforehand.

JavaScript has its limitation and cannot do magic to everything.

Hi Donald,
                 Thanks for the explanation. I could understand how they really work. And the limitations which javascript pose. Might be using Java API, we can try this out. If you can suggest me an sample code for this. Since I was new to the server extension development.

Try to avoid doing something that brings no or little benefit. If the logic is on the server side, there is really no need for another "check". If an attribute is mandatory but has no value during the save, the save operation will fail and an error is returned to the client.

I suggest you draw the workflow on a piece of paper so that you can "see" it. Then you can see which part of the workflow you can inject your extra logic, and where it makes sense there.

1 vote


One other answer

Permanent link

You can determine that in the Java Server API, but not with attribute customization (at least not with any published API). See https://rsjazz.wordpress.com/2015/08/07/a-custom-condition-to-make-attributes-required-or-read-only-by-role-version-2/

I would not touch that if I could avoid it, as it is really an ugly construct. In addition I agree with Donald, that you should use the mechanisms the UI provides and stay with them.

Why I post examples that I would suggest not using? Because users won't listen.

Also see https://rsjazz.wordpress.com/2016/07/15/rtc-process-customization-what-you-can-and-cannot-do/

0 votes

Your answer

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,934

Question asked: Jul 14 '17, 9:35 a.m.

Question was seen: 2,465 times

Last updated: Jul 26 '17, 2:56 a.m.

Confirmation Cancel Confirm