Mandatory field required based on State change
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2013 01:10 PM
Hi all,
I am trying to figure out how to get a field on the defect form to be set to mandatory when a state change happens. I am trying to make a field (u_product_version_tested) on the rm_defect form mandatory when the state goes from Development Done or Test back to Ready. In addition, if the state changes from any state to Test Done, make the Product Version Tested field mandatory. I do NOT want the field to be mandatory when the state goes from New to Ready or Development back to Ready.
I tried creating a UI Policy, where the condition = state is one of Ready or Test Done. But, anytime Ready was selected as a state (such as New > Ready) it made the field mandatory. Which as I mentioned above, I don't want to happen. Is this possible??? Do I have to use a run script condition for this and if so, can someone help with that as well? I don't have much, if any, scripting background. I would greatly appreciate any help :)!!
States (state, value):
New, 13
Ready, 12
Development, 14
Development Done,15
Test, 16
Test Done, 17
Deployed,18
Cancelled, 7
Deferred,20
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2013 11:52 PM
I think you'd need to look at scripting this... thinking aloud, you'd probably want an onChange client script on your state field that checks the oldValue and the newValue, e.g.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue == '') {
return;
}
if ((oldValue == 'New' || oldValue == 'Blah') && (newValue = 'Ready')) {
g_form.setMandatory('u_product_version_tested', true);
} else {
g_form.setMandatory('u_product_version_tested', false);
}
}
You'll have to consider if you also want a Business Rule to check that the submission has been done correctly, or if you're happy that this check can just be done in the browser.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2013 01:45 PM
Thanks ssb :)!
I ended up doing a client script and had to tweak some things, but it works perfect for what I need.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue == '') {
return;
}
if (newValue == 'Test Done') {
g_form.setMandatory('u_product_version_tested', true);
return;
}
if ((oldValue == 'New' || oldValue == 'Blah') && (newValue == 'Ready')) {
g_form.setMandatory('u_product_version_tested', true);
} else {
g_form.setMandatory('u_product_version_tested', false);
}
}
