
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2012 07:01 AM
I need to make a catalog item variable mandatory on only one task. I do not need it to be mandatory when submitted, I just need it to be mandatory on one of the tasks that get generated by the workflow.
Thanks for the help.
Jason
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-09-2012 07:33 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-06-2012 10:58 AM
temporarily comment out everything except the lines where you set and fill your variables. Then add an alert and see if its really pulling the values or if you get something like 'undefined' as a response. That's generally the first thing I do on a script where Im not getting the reaction I expect.
var task_state = g_form.getValue('state');
var lease_new_comp = g_form.getValue('variables.lease_new_computer');
alert("Task state is: " + task_state + " and the value of Lease New Computer is " + lease_new_comp);
If it alerts the right values then you know your problem is in your if comparison.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-06-2012 12:17 PM
Good tip - it helped. I went with a mix of you guys' suggestions. I'm trying an onsubmit() script and using
g_form.setMandatory('variables.lease_new_computer', true);
At the time of evaluation my state is 1, which is is my issue, so I'm not setting the field to mandatory. I need to be making this evaluation after the state is 3. I would think that "close task" would instantly be changing this state before I hit my client script, but I guess not. How do I get around that??

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-06-2012 11:06 AM
Use
g_form.setMandatory('variables.myField', true);
I would also use an onSubmit script instead of a onChange. Then you can check the state when they submit the record and if it is not filled out then you can prevent save.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2012 02:22 AM
I added an action name of "close_task" to the close button and keyed off of that. This was the only way I saw to get around the state not actually being 3 when the script ran. So - I just ran it on click of the button. Thank you both for the help!!
Jason
function onSubmit() {
var action = g_form.getActionName();
var task_state = g_form.getValue('state');
if (action == 'close_task') {
var lease_new_computer = g_form.getValue('variables.lease_new_computer');
if (lease_new_computer == '') {
alert('New Machine Is Mandatory!');
g_form.setMandatory('lease_new_computer', true);
return false;
}
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-09-2012 04:00 AM
Just an FYI if a UI Action does not have the "Client" check box selected then it runs on the server which is to say it will run after any client side code. What you did was the only way I know of to do this kind of thing.