It's all about the answers!

Ask a question

how to make comments field mandatory when a state changes in RTC?


Don Yang (7.7k21114139) | asked Oct 31 '16, 5:13 a.m.
RTC 5.0.2 used.

In the below discussions,

https://jazz.net/forum/questions/178039/is-it-possible-to-make-the-comments-field-required-as-part-of-a-state-change-in-rtc

We understand that the built-in comments(in discussion attribute) can not be set as mandatory attribute in the existing precondition 'required attributes for type and state'.
There is a suggestion to use a custom attribute for comments and then set is as mandatory filed at a specific state.
Geoff suggested that there is limitation for this approach:
===
Note that this would work only if there was only a single state that needed a comment, and that when they transitioned out of that state, and then back into it, they didn't need an additional comment.  One could handle different comments for different states by having multiple comment fields, i.e. "done-comment", "open-comment", "verified-comment", but that still would not deal with transitioning multiple times into a given state.
===
To workaround that limitation, there is an idea to copy the user comments in the custom attribute into the Discussion field and then empty that custom attribute itself, and when the state changes to other state, we want to empty that attribute so that it can become mandatory again when transitioning multiple times into a specific state.

1) is there any type of java script to be used to copy the string from custom attribute into discussion field?
2) is there any type of java script to be used to empty the custom attribute(reset) at some states?
Any other suggestion to achieve the use case if javascript is not an option?

Please shed some lights on this. Thanks a lot.

Accepted answer


permanent link
Ralph Schoon (63.5k33646) | answered Oct 31 '16, 5:41 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
edited Oct 31 '16, 5:44 a.m.
I don't see how you could implement this with JavaScript attribute customization. The approach to take here is to use a follow up action / participant to do the copying (the copying could also create a comment then) and attribute clearing after the save. See https://rsjazz.wordpress.com/?s=participant for examples. Please note several additional problems in your requirement/implementation proposal:
  • The attribute you make required can not be cleared in that state - because it is required after the state has been set, it will still be required
  • You would have to create a custom precondition or condition that detects that there is a state change and only then requires the attribute to copy; see https://rsjazz.wordpress.com/2015/06/19/a-custom-condition-to-make-attributes-required-or-read-only-by-role/ for a possible way to do this

Maybe it would be possible to create a precondition that actually checks if a state change happens and a new comment has been added and prevent a save. This way you could enforce the rule and would avoid all the complicated rest of the business here. You would not be able to show that the comment is required, but you could show it in the error on save.
Don Yang selected this answer as the correct answer

Comments
Don Yang commented Oct 31 '16, 8:39 p.m.

Thanks Ralph for the suggestions.
===
Maybe it would be possible to create a precondition that actually checks if a state change happens and a new comment has been added and prevent a save. This way you could enforce the rule and would avoid all the complicated rest of the business here. You would not be able to show that the comment is required, but you could show it in the error on save.
==
Here comment is the custom attribute not the discussion field's comment, is that right?


Ralph Schoon commented Nov 01 '16, 3:36 a.m. | edited Nov 01 '16, 3:37 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Yes. You can detect a state change and likely an added comment in a precondition. I have however not tried detecting a new comment was added.


Don Yang commented Nov 02 '16, 12:08 a.m.

Thanks a lot for the info.

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.