Hello all,
I have a use case that requires that supervisors have the ability to override the required fields during the entry of data - mainly because they do not have access to the data or it was not included on an application, etc. Their intent is to require certain fields, such as, company name, address, city, phone, and others, but, if the application does not contain the phone number, the would like to be able to temporarily override the requirements until the information is obtained and continue the setup operation.
Has anyone dealt with this issue? I have included an '_override' field as part of the BO, only available to those in particular roles, that 'turns off' the validationrules.addrule lines for the AddValidationRules() method, something like this:
if (!_override){ ValidationRules.AddRule(...StringRequired, "Phone"); etc. }
Will this even work? Is the rule already loaded by the time the user selects the 'Override' checkbox?
Thanks in advance for any help,
Kelly.
Hey Andy,
Thanks for the reply. I guess since I had several requirements that were affected by this, I tried to take a shortcut and cover them all at the same time, but, after looking at it in greater detail, and considering this is a rather small piece of the whole pie, it would be better to get it right the first time - even if it does take a little longer and requires a little more code. So, for each conditional requirement I used something like this:
In the AddBusinessRules():
ValidationRules.AddRule(PhoneRequired, "Phone");
And just below:
private bool PhoneRequired(object target, Csla.Validation.RuleArgs e)
{
if (!_override & (_phone.Length == 0))
{
e.Description = "Phone Number is required";
return false;
}
else
return true;
}
Does that look similar to your thinking?
Thanks again,
Kelly.
Maybe these are not required fields.
Maybe you have a property on your application that determines whether or not an application is "complete", which checks to see if everything is supplied in order to meet completeness.
Another option might be to use "Warning" business rules that allow saving but presents warning messages that "address is not supplied", etc.
The other option is what you're mentioning - though I'd almost go as far as making this a property "Override Application Required Fields" and potentially put write access security on that property so that only some users could skip required fields by selecting this. I would also make this a persistant property of the BO, so that someone else pulling up the record is able to manipulate it if they're doing something unrelated to the required fields that someone else didn't supply.
Hey,
Thanks for the reply...They are actually required fields; however, due to the nature of the biz, on rare occasion, we receive an incomplete application and decide to force the app into the system to keep from holding up the process. Of course, there are certain fields that are "More Required" than others and cannot be overridden.
I do like the idea of the "Warning Rules" and will look into that a little further.
The "Override" feature is definately role-based so that only supervisors and sys-admins can use it; you just can't have it any other way.
Thanks again,
Kelly.
Copyright (c) Marimer LLC