make some fields mandatory on particular catalog task while submitting

tarun43
Tera Contributor

Hi everyone

I have two catalog tasks in my workflow.

these three fields are not mandatory on catalog. 

these three fields should be mandatory before closing the last task by the agent.

i am trying this script but. task is not reverting to open if these three fields are empty then also

the RITM must also not complete if fields are empty

 

catalog client script:

function onSubmit() {
    if (g_form.getValue('short_description') == 'Install approved new software ') {

        g_form.setMandatory('current_version'true);{
        g_form.addErrorMessage('current version is empty!');
        }


        g_form.setMandatory('publisher'true);{
        g_form.addErrorMessage('Publisher is empty!');
        }
        // To make mandatory

        g_form.setMandatory('software_Edition'true);{
        g_form.addErrorMessage('software edition is empty!');
        }

        if("software_Edition"==""||"publisher"==""||"current_version"==""){
            g_form.setValue('state') == 1;
        }
        else{}
    } else {

    }
    //Type appropriate comment here, and begin script below

}
 
thanks in advance..
tarun 
4 REPLIES 4

umaaggarwal
Giga Guru
Giga Guru

I would suggest do not change the state in client script. just return true or false based on your validations. 

If you will return false, it will anyway not change the state and if you return true, it will allow you to submit. 

Tried "return false"  , still form is getting submitted

Eswar Chappa
Mega Sage
Mega Sage

Hi @tarun43 i was not getting the exact use with your above statement and code, can you please elaborate it.

 

Thanks & Regards,

Eswar Chappa

I have two catalog tasks.

I want three fields to be mandatory on the 2 nd catalog task and if those fields are not filled by agent then task should not get closed