- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2017 07:12 AM
The script below is making the field mandatory but once a value is entered and we hit update, it's still prompting for the mandatory field. I've got this setup as a submit but thinking maybe it should be onChange. Maybe when the state changes or the Title. We have another script prompting and based on the answer, we're changing the Title to one of the below.
function onSubmit() {
//Type appropriate comment here, and begin script below
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var action = g_form.getActionName();
task_state = g_form.getValue('state');
task_sd = g_form.getValue('short_description');
task_assignment = g_form.getValue('assignment_group');
if(((task_sd=="Delete - Program Request - Release DB2")
|| (task_sd=="Delete - Program Request - Release DB2 & Disable CICS")
|| (task_sd=="Delete - Program Request - Disable CICS"))
&& ((task_assignment =='7a8232270a0a3c1f01cae985bf9ffdcf') && (task_state=='3'))){
var remove_program =g_form.getValue('u_remove_program_from_db2_or_cics');
if (remove_program == "");
alert('Remove program from DB2 or CICS is mandatory');
g_form.setMandatory('u_remove_program_from_db2_or_cics', true);
} else
{
g_form.setMandatory('u_remove_program_from_db2_or_cics',false);
}
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2017 06:30 AM
Wanted to thank everyone for their help. I decided to get rid of the client scripts and just add a couple new fields to the change task form, and use UI Policy's to show and make them mandatory. Then changed the workflow to use scratchpad to capture the information on the change task to auto assign the task. Much cleaner....thanks again.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2017 07:16 AM
can you remove the below line from your script
function onSubmit() {
//Type appropriate comment here, and begin script below

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2017 07:17 AM
Hi Andrea,
Looks like you might want to change if (remove_program == ""); to if (remove_program == "") { and then close out the bracket where appropriate.
If I'm reading this right, you should be able to use a ui policy to set the field mandatory which would be a lot simpler.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2017 11:05 AM
Hey Brad,
I'm thinking part of my problem is this other client script that we're using to set the Title. I'd like to make the fields mandatory within this same client script if possible. Of course, I tried just adding the setMandatory but it didn't work. The UI Policy didn't work for us, since we're setting the title on Submit, of course if we go back into the ctask, then it's mandatory.
function onSubmit() {
var action = g_form.getActionName(),
task_state = g_form.getValue('state'),
task_sd = g_form.getValue('short_description'),
task_assignment = g_form.getValue('assignment_group'),
new_shortdesc;  
if((task_sd=="Delete - Program Request") && (task_state=='3') && (task_assignment =='7a8232270a0a3c1f01cae985bf9ffdcf')){
var return_answer = prompt('Create Task Options (Choose The Number): \n0 - No Task Needed\n1 - Release DB2\n2 - Disable CICS\n3 - Release DB2 & Disable CICS');
if (return_answer == '0'){ 
new_shortdesc = task_sd + " - no additional Task needed";
g_form.setValue('short_description', new_shortdesc);
}
else if (return_answer == '1'){ 
new_shortdesc = task_sd + " - Release DB2";
g_form.setValue('short_description', new_shortdesc);
//g_form.setMandatory('u_remove_program_from_db2_or_cics', true);
}
else if (return_answer == '2'){ 
new_shortdesc = task_sd + " - Disable CICS";
g_form.setValue('short_description', new_shortdesc);
//g_form.setMandatory('u_remove_program_from_db2_or_cics', true);
}
else if (return_answer == '3'){ 
new_shortdesc = task_sd + " - Release DB2 & Disable CICS";
g_form.setValue('short_description', new_shortdesc);
//g_form.setMandatory('u_remove_program_from_db2_or_cics', true);
}
else{
return false;
}
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2017 11:21 AM
ok do one thing put alert() to validate which if() is working or which one is not. by the way what is the purpose of the below line?
new_shortdesc = task_sd + " - Release DB2 & Disable CICS";
i don't think this way you will set the value. and your first if condition will execute when all condition will fulfill because you have used and operator.
may i know you are doing it in PDI then i can have look into this.