- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2023 07:17 PM
Hi, There. It's Ken.
I want to require Serial Number depending on the Model Category selection.
I want to make Serial Number mandatory when Computer and Smart Device are selected in Model Category.
First, I created a UI Policy to make it a mandatory input.
However, I found that it conflicted with "MC - Make serial number mandatory" in Client Script.
I have confirmed that the UI Policy works by deactivating "MC - Make serial number mandatory".
I would prefer not to deactivate "MC - Make serial number mandatory".
After code analysis, it seems that the Model Category parameter is checked.
Please tell me how to make Serial Number mandatory when Computer and Smart Device are selected in Model Category.
Thanks,
Ken.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2023 03:23 AM
Hi @Kentaro Numata ,
You can achieve this by using a client script that runs on the form load event and checks the value of the Model Category field. If the selected value is Computer or Smart Device, then make the Serial Number field mandatory using the setMandatory() function. Here's an example script:
function onLoad() {
var modelCategory = g_form.getValue('model_category');
if (modelCategory == 'computer' || modelCategory == 'smart_device') {
g_form.setMandatory('serial_number', true);
}
}
Thanks,
Ratnakar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2023 03:23 AM
Hi @Kentaro Numata ,
You can achieve this by using a client script that runs on the form load event and checks the value of the Model Category field. If the selected value is Computer or Smart Device, then make the Serial Number field mandatory using the setMandatory() function. Here's an example script:
function onLoad() {
var modelCategory = g_form.getValue('model_category');
if (modelCategory == 'computer' || modelCategory == 'smart_device') {
g_form.setMandatory('serial_number', true);
}
}
Thanks,
Ratnakar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2023 04:08 AM - edited 04-21-2023 05:55 AM
Hi @Kentaro Numata ,
Can you confirm whether serial number should be mandatory only when Computer and Smart Device are selected in Model Category? and check the order of the Client script which make the serial number mandatory?
If it is the requirement then write a Ui policy on the model category, and in conditions specify Model Category field "is not" computer or smart device. And in ui policy action add the serial number and make mandatory false. As the Ui policies executes after the Client script it make the serial number non mandatory for all conditions
or else go for the same client script which make the serial number mandatory and specify the conditions as above @Ratnakar7 mentioned.