It's all about the answers!

Ask a question

How To Create Simple Script to Validate Attribute Value and Force Entry Before Save


Rob Olsen (3512153) | asked Jan 13 '15, 4:45 p.m.
edited Jan 13 '15, 4:46 p.m.

I am in the process of using the Milestone Work Item as a baseline template and reconfiguring it for a specific project.  In one of the requirements, if a certain attribute is set to "No", then another string field is not required and an entry can be "Saved".  If the attribute is set to "Yes" then the string field needs an entry before a "save" can be executed.  I am using a custom attribute (attrYesNo).

First question: should I be using a longer structured ID name?  Most other attributes use "com.ibm.team.workitem.attribute....", I just used the above.

Second, where can I find more examples of a script that evaluates the literal value of "attrYesNo" so that if it is "Yes" then the person is required to enter a string in another field on the screen before a "save" can be performed.  And if "No", then a "save" can be performed without the string entered.


Comments
sam detweiler commented Jan 14 '15, 6:42 a.m.

Just so you understand, the process with these pre-conditions is to allow the save or prevent the save with an error message. They do not provide for any additional prompting or UI functionality.

Accepted answer


permanent link
Don Yang (7.7k21114139) | answered Jan 13 '15, 11:34 p.m.
Using "dynamic required attributes" (in later version, it is Required Attributes For Condition)precondition, you should be able to achieve what you expect. The concept and sample condition script is in the Help:

https://jazz.net/help-dev/clm/index.jsp?re=1&topic=/com.ibm.team.workitem.doc/topics/t_configuring_dynamic_required_attributes.html&scope=null

Some more scripts can be found in https://jazz.net/library/article/537(checking with Required Attributes For Condition section) or searching in the forum can also find a lot of scripting discussions.

Hopefully this helps.
Rob Olsen selected this answer as the correct answer

Comments
Ralph Schoon commented Jan 14 '15, 7:08 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Also see https://jazz.net/library/article/1093 Lab 4 and 5 for a comprehensive list of examples for conditions.


Ralph Schoon commented Jan 14 '15, 7:10 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

PS: I usually suggest to come up with a reasonable ID structure for customizations e.g. com.mycompany.... because this makes searching for customizations in the process XML way easier.


Rob Olsen commented Jan 14 '15, 10:17 p.m.

Awesome, thanks!

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.