- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2023 11:30 AM
Hello,
We have a Vendor Manager List type field on the Company table which references the user table. Is there a way to prevent users from entering more than 1 name in the Vendor Manager field being that it is a list type?
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2023 11:38 AM - edited 10-11-2023 11:38 AM
Hi @George56 ,
You can achieve this by creating an onChange client script on vendor management field
(function() {
// When Vendor Manager field changes
function onChangeVendorManager() {
var vendorManagerField = g_form.getValue('vendor_manager'); // Replace 'vendor_manager' with the actual field name
var enteredNames = vendorManagerField.value.split(','); // Assuming names are separated by commas
if (enteredNames.length > 1) {
alert('Please enter only one name in the Vendor Manager field.');
vendorManagerField.value = enteredNames[0]; // Set the field value to the first name entered
}
}
})();
Please modify the script as per your need.But the basic idea is on change of the field fetch the value check the length by splitting it with comma n validating of it's more than 1 or not. If more than 1 give some alert or fieldmessage.
Mark my answer helpful & accepted if it helps you resolve your query.
Thanks,
Danish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2023 11:38 AM - edited 10-11-2023 11:38 AM
Hi @George56 ,
You can achieve this by creating an onChange client script on vendor management field
(function() {
// When Vendor Manager field changes
function onChangeVendorManager() {
var vendorManagerField = g_form.getValue('vendor_manager'); // Replace 'vendor_manager' with the actual field name
var enteredNames = vendorManagerField.value.split(','); // Assuming names are separated by commas
if (enteredNames.length > 1) {
alert('Please enter only one name in the Vendor Manager field.');
vendorManagerField.value = enteredNames[0]; // Set the field value to the first name entered
}
}
})();
Please modify the script as per your need.But the basic idea is on change of the field fetch the value check the length by splitting it with comma n validating of it's more than 1 or not. If more than 1 give some alert or fieldmessage.
Mark my answer helpful & accepted if it helps you resolve your query.
Thanks,
Danish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2023 12:41 PM
Thanks Danish. I had to make a couple minor changes, but this got me down the right path, Thanks again.