- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-28-2016 11:30 AM
Hi All,
I have an onSubmit client script that alert's the user when they attempt to submit/update a Change Request to a specific 'state' and they do not have a required role. This seems to be working fine, however I wanted to add some logic where if the Change Request is already in that specific state, that they are able to save/update the record. We just don't want them to be able to submit or update to that state from a previous state. Hope that makes sense. any help is appreciated. Thanks everyone!
Fred
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-29-2016 06:51 AM
Hi Fred,
Great work!
As far as I know, disableOption() is not a method/function that comes OOB. Using g_form.removeOption() is the most common way.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-29-2016 06:51 AM
Hi Fred,
Great work!
As far as I know, disableOption() is not a method/function that comes OOB. Using g_form.removeOption() is the most common way.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-28-2016 11:44 AM
var state = g_form.getControl('state');
if(state.changed && g_form. --your condition)
{
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-28-2016 11:58 AM
Wouldn't an onChange client script on the state field solve your issue? Something like this:
if(newValue == '10' && !g_user.hasRole('cab_approver')){
alert('Sorry! You are not authorized to change the state to "Ready for Deployment"');
g_form.setValue('state', oldValue);
}
This will check for user role and the changed state, so if the state is already in that state, it wouldn't even kick off.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-28-2016 12:01 PM
The catch with the onChange script is that it does not stop someone from submitting the form even after they set the wrong value. The only way around that is to clear the value and set the field to mandatory so they cannot submit until they pick the right value.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-28-2016 12:16 PM
Of course, but i thought this line: g_form.setValue('state', oldValue); would solve that part, where it sets the state back to the older value?
