Client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2025 03:49 AM
Hi All,
I have a requirement to make the location field blank and mandatory on alm_asset form on every change of state field.
Once the state value changes, the location field should be blank and mandatory, so that the user can fill the location manually and update the asset form.
I have written the onChange client script on State field but it is not working.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if (newValue == 1 || newValue == 2 || newValue == 3 || newValue == 6 || newValue == 7 || newValue == 8 || newValue == 9 || newValue == 10 || newValue == 11) {
g_form.clearValue('location');
g_form.setMandatory('location', true);
g_form.addErrorMessage('Please fill the Location field before saving the record');
return false;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2025 04:39 AM
@Chaitanya ILCR Now my script is working. The issue was the table on which I have written the client script. I noticed that once I open the asset form, it is opening alm_hardware form and not slm_asset form.
So I changed the table and now the script is working fine.
Thanks,
Rooma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2025 04:30 AM
you don't need to list all the states. if you are doing an onChange on the state field just do this
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
g_form.clearValue('location'); // Blank it
g_form.setMandatory('location', true); // Make it mandatory
}