mandatory field in task and Hidden on the Catalog Item

Nawal
Mega Guru

Hi, 

i have a question regarding a field to be diplayed Mandatory only on a specific task.

I tried a simple ui policy but it forces display on the Item.

find_real_file.png

 

same if i check mandatory box!!

and also with a client script :   g_form.setMandatory('variables.example', true);

Any idea how to do please?

 

thank you so much 

1 ACCEPTED SOLUTION

Hi,

Use this

function onLoad() {
//Type appropriate comment here, and begin script below


//task.u_task_name = "Build contract";

if(g_form.getValue('u_task_name')=="Build contract")
{
g_form.setMandatory('can_you_please_specify', true);
else{
g_form.setMandatory('can_you_please_specify', false);
}
}
-Anurag

View solution in original post

9 REPLIES 9

I tried this : 

but it s not working, i think it s not good 

 

function onLoad() {
//Type appropriate comment here, and begin script below


//task.u_task_name = "Build contract";

var task =new GlideRecord('sc_task');

task.addQuery('u_task_name', "Build contract");

task.query();

if(task.next())

{

g_form.setMandatory('can_you_please_specify', true);

}

}

Hi,

Use this

function onLoad() {
//Type appropriate comment here, and begin script below


//task.u_task_name = "Build contract";

if(g_form.getValue('u_task_name')=="Build contract")
{
g_form.setMandatory('can_you_please_specify', true);
else{
g_form.setMandatory('can_you_please_specify', false);
}
}
-Anurag

Hi Anurag,

it works !!

 

thank you so much.

function onLoad() {
//Type appropriate comment here, and begin script below


//task.u_task_name = "Build contract";

if(g_form.getValue('u_task_name')=="Build contract")
{
g_form.setMandatory('can_you_please_specify', true);
}
else{

g_form.setMandatory('can_you_please_specify', false);
g_form.setDisplay('can_you_please_specify', false);
}
}

sai krishna10
Giga Guru

Hi Nawal,

 

Create a UI Policy with the below condition to run only on catalog items and in the UI Policy Action select the  variable and make the visible to false.

find_real_file.png 

 

Create one more UI Policy with the below condition so that it will run only on task and in the UI Policy condition select the variable and make the mandatory to true.

find_real_file.png

 

Thanks

Sai Krishna

Kindly mark the answer as correct/helpful if it solves your issue.

Hi, 

thank you for this suggestion.