This may be a really basic question but I’m having trouble figuring out how to make a Combo Box a required field. I want to force a user to always select a Class and Group value on a part. The Properties tab doesn’t seem to have a checkbox for that though. Do I need to create an event/data rue to make this happen?
Hey Dave,
This can be done with a BPM on the pre-processing for update.
When update is called, before we actually save, we want to confirm that this field is populated. If this is not populated, throwing an exception inside the BPM will halt the update process and not allow the user to save.
Here is an example from my end:
Custom code component:
List<string> allErrors = new List<string>();
foreach (var custCnt in ds.CustCnt)
{
List<string> errors = new List<string>();
string contactName = !string.IsNullOrWhiteSpace(custCnt.Name) ? custCnt.Name.Trim() : "(Unnamed Contact)";
if (string.IsNullOrWhiteSpace(custCnt.Name))
errors.Add("• Contact Name is required.");
if (string.IsNullOrWhiteSpace(custCnt.RoleCode))
errors.Add("• Contact Role is required.");
if (string.IsNullOrWhiteSpace(custCnt.PhoneNum) && string.IsNullOrWhiteSpace(custCnt.CellPhoneNum))
errors.Add("• At least one phone number (PhoneNum or CellPhoneNum) is required.");
if (string.IsNullOrWhiteSpace(custCnt.EMailAddress))
errors.Add("• Email Address is required.");
if (errors.Count > 0)
allErrors.Add($"*{contactName}* needs the following updates:\n{string.Join("\n", errors)}");
}
if (allErrors.Count > 0)
throw new Ice.BLException("Please correct the following issues:\n\n" + string.Join("\n\n", allErrors));