It's all about the answers!

Ask a question

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


Vignesh ramamoorthy Muniyandy (15410) | asked Jul 14 '17, 9:35 a.m.
edited Jul 17 '17, 12:20 a.m.

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.

Accepted answer


permanent link
Donald Nong (14.5k614) | answered Jul 17 '17, 2:55 a.m.

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

Comments
Vignesh ramamoorthy Muniyandy commented Jul 17 '17, 9:58 a.m.

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.


Donald Nong commented Jul 19 '17, 2:27 a.m.

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.


Vignesh ramamoorthy Muniyandy commented Jul 25 '17, 11:50 p.m.

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.


1
Donald Nong commented Jul 25 '17, 11:59 p.m.

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.

One other answer



permanent link
Ralph Schoon (63.5k33646) | answered Jul 26 '17, 2:52 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
edited Jul 26 '17, 2:56 a.m.

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/

Your answer


Register or 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.