cmdb_ci field mandatory in SCTASK

barbaratosetto
Tera Contributor

 

Hello everyone!

I need to make the cmdb_ci field mandatory in SCTASKs created by a Flow Designer flow.

I initially achieved this using a UI Policy, but my boss suggested that it would be more efficient to handle this requirement inside Flow Designer.

After researching, I realized that Flow Designer cannot directly make a field mandatory — but it could be done using a Client Script.

So, I created the following Client Script:


function onLoad() {
// Retrieve the Short Description field
var shortDesc = g_form.getValue('short_description').trim().toLowerCase();

// Check if the Short Description matches 'deploy'
if (shortDesc == 'deploy') {
// Make the CI field mandatory
g_form.setMandatory('cmdb_ci', true);
}
}

 

In the Flow Designer, I’m populating the short_description field with "Deploy" (see attached screenshots).

However, the cmdb_ci field is still not mandatory when the SCTASK loads.

 

I have checked and there are no UI Policies interfering in the cmdb_ci field. 

 

Has anyone faced a similar situation or knows what might be missing?

Thanks in advance for any help!

barbaratosetto_0-1749055118511.pngbarbaratosetto_1-1749055153737.png

 

 

1 REPLY 1

Chaitanya ILCR
Kilo Patron

Hi @barbaratosetto ,

 

your script should work just check if there anything that is overriding (like UI policies or any other Client script)

 

what you had done was correct using the UI policy

better to go with UI policy only 

 

It's not going to make any difference making a field mandatory using client script or UI policy when possible 

why to complicate things  (when you can use the low code UI policies

 

 

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya