case 4615
This commit is contained in:
@@ -7,7 +7,7 @@ namespace AyaNova.Biz
|
|||||||
{
|
{
|
||||||
internal static class CustomFieldsValidator
|
internal static class CustomFieldsValidator
|
||||||
{
|
{
|
||||||
internal static void Validate(BizObject biz, FormCustom formCustom, string customFields)
|
internal static void Validate(BizObject biz, FormCustom formCustom, string customFields, string onlyIfStartsWith = null)
|
||||||
{
|
{
|
||||||
bool hasCustomData = !string.IsNullOrWhiteSpace(customFields);
|
bool hasCustomData = !string.IsNullOrWhiteSpace(customFields);
|
||||||
|
|
||||||
@@ -15,9 +15,14 @@ namespace AyaNova.Biz
|
|||||||
if (formCustom == null)
|
if (formCustom == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
|
//case 4615
|
||||||
|
bool checkPrefix = !string.IsNullOrEmpty(onlyIfStartsWith);
|
||||||
|
|
||||||
var FormTemplate = JArray.Parse(formCustom.Template);
|
var FormTemplate = JArray.Parse(formCustom.Template);
|
||||||
var ThisFormCustomFieldsList = FormFieldOptionalCustomizableReference.FormFieldReferenceList(formCustom.FormKey).Where(z => z.IsCustomField == true).Select(z => z.TKey).ToList();
|
var ThisFormCustomFieldsList = FormFieldOptionalCustomizableReference.FormFieldReferenceList(formCustom.FormKey).Where(z => z.IsCustomField == true).Select(z => z.TKey).ToList();
|
||||||
|
|
||||||
|
|
||||||
//If the customFields string is empty then only validation is if any of the fields are required to be filled in
|
//If the customFields string is empty then only validation is if any of the fields are required to be filled in
|
||||||
if (!hasCustomData)
|
if (!hasCustomData)
|
||||||
{
|
{
|
||||||
@@ -28,6 +33,10 @@ namespace AyaNova.Biz
|
|||||||
var fldKey = FormTemplate[i]["fld"].Value<string>();
|
var fldKey = FormTemplate[i]["fld"].Value<string>();
|
||||||
var fldRequired = FormTemplate[i]["required"].Value<bool>();
|
var fldRequired = FormTemplate[i]["required"].Value<bool>();
|
||||||
//Check if this is an expected custom field and that it was set to required
|
//Check if this is an expected custom field and that it was set to required
|
||||||
|
|
||||||
|
//case 4615
|
||||||
|
if (checkPrefix)
|
||||||
|
continue;
|
||||||
if (ThisFormCustomFieldsList.Contains(fldKey) && fldRequired == true)
|
if (ThisFormCustomFieldsList.Contains(fldKey) && fldRequired == true)
|
||||||
{
|
{
|
||||||
//Ok, this field is required but custom fields are all empty so add this error
|
//Ok, this field is required but custom fields are all empty so add this error
|
||||||
@@ -50,6 +59,14 @@ namespace AyaNova.Biz
|
|||||||
//make sure all the *required* keys are present
|
//make sure all the *required* keys are present
|
||||||
foreach (string iFldKey in ThisFormCustomFieldsList)
|
foreach (string iFldKey in ThisFormCustomFieldsList)
|
||||||
{
|
{
|
||||||
|
//case 4615
|
||||||
|
//ensure descendant custom fields are only checked against matching descendant objects
|
||||||
|
if (checkPrefix && !iFldKey.StartsWith(onlyIfStartsWith))
|
||||||
|
continue;
|
||||||
|
//ensure when validating work order header don't check workorder item custom fields as both could be present here
|
||||||
|
if (!checkPrefix && iFldKey.StartsWith("WorkOrderItem"))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
|
||||||
//Translate the LT field key to the actual customFieldData field key
|
//Translate the LT field key to the actual customFieldData field key
|
||||||
var InternalCustomFieldName = FormFieldOptionalCustomizableReference.TranslateLTCustomFieldToInternalCustomFieldName(iFldKey);
|
var InternalCustomFieldName = FormFieldOptionalCustomizableReference.TranslateLTCustomFieldToInternalCustomFieldName(iFldKey);
|
||||||
|
|||||||
@@ -1512,7 +1512,7 @@ namespace AyaNova.Biz
|
|||||||
RequiredFieldsValidator.Validate(this, FormCustomization, proposedObj);//note: this is passed only to add errors
|
RequiredFieldsValidator.Validate(this, FormCustomization, proposedObj);//note: this is passed only to add errors
|
||||||
|
|
||||||
//validate custom fields
|
//validate custom fields
|
||||||
CustomFieldsValidator.Validate(this, FormCustomization, proposedObj.CustomFields);
|
CustomFieldsValidator.Validate(this, FormCustomization, proposedObj.CustomFields, "WorkOrderItem");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1748,7 +1748,7 @@ namespace AyaNova.Biz
|
|||||||
RequiredFieldsValidator.Validate(this, FormCustomization, proposedObj);//note: this is passed only to add errors
|
RequiredFieldsValidator.Validate(this, FormCustomization, proposedObj);//note: this is passed only to add errors
|
||||||
|
|
||||||
//validate custom fields
|
//validate custom fields
|
||||||
CustomFieldsValidator.Validate(this, FormCustomization, proposedObj.CustomFields);
|
CustomFieldsValidator.Validate(this, FormCustomization, proposedObj.CustomFields, "WorkOrderItem");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2566,7 +2566,7 @@ namespace AyaNova.Biz
|
|||||||
RequiredFieldsValidator.Validate(this, FormCustomization, proposedObj);//note: this is passed only to add errors
|
RequiredFieldsValidator.Validate(this, FormCustomization, proposedObj);//note: this is passed only to add errors
|
||||||
|
|
||||||
//validate custom fields
|
//validate custom fields
|
||||||
CustomFieldsValidator.Validate(this, FormCustomization, proposedObj.CustomFields);
|
CustomFieldsValidator.Validate(this, FormCustomization, proposedObj.CustomFields, "WorkOrderItem");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user