Make field mandatory

Abdul
Tera Contributor

Hi

 

Whenever the below "Dispatch" field  is read only then the field named Part Information should be made mandatory.

And Dispatch field gets to be readonly when the form is saved.

So when the dispatch field is checked the part information should not be visible and only when the form gets saved and the dispatch field is read only the part information field is made visible and mandatory

How can we do that

Abdul_0-1759294531544.png

 

1 ACCEPTED SOLUTION

svirkar420
Tera Guru

Hi @Abdul , try the onLoad script below, if this is on catalog form then use catalog client script

Script:

 

function onLoad() {
var dispatchField = 'dispatch';
var partInfoField = 'part_information';

var isDispatchChecked = g_form.getValue(dispatchField) == 'true';
var isDispatchReadOnly = g_form.isReadOnly(dispatchField);

if (isDispatchReadOnly && isDispatchChecked) {
g_form.setVisible(partInfoField, true);
g_form.setMandatory(partInfoField, true);
} else {
g_form.setVisible(partInfoField, false);
g_form.setMandatory(partInfoField, false);
}
}

 

If this solution helps you please don't forget to mark this solution as accepted and helpful, this will help others as well.

Regards,

Saurabh V.

 

View solution in original post

4 REPLIES 4