How to make fields as mandatory in document definition based on condition ?


i have 2 types of invoices  X & Y and i created my own document definition from flexi layout studio which contains couple of fields say

1.Date 2. ID 3. Total Amount 4. Identifier

Difference between 2 invoices is where Identifier field will be not available in invoice X.

Date & ID are both mandatory fields in both the invoices X & Y and i made them as mandatory which is working fine.

Now Total Amount is mandatory for the invoice X where Identifier field is not available and the same way             Total Amount is not mandatory for the invoice Y where identifier is available.

Here i am unable to make TotalAmount as  mandatory for only Invoice X. Below is the code i have added in the field level rules (TotalAmount) in the document definition. Can you please help here.

if (( Context.Field("Identifier").Text == "" )& (Context.Field("TotalAmount").Text == ""))
Context.Field("TotalAmount").Value = false;
Context.CheckSucceeded = false;
Context.ErrorMessage = FCTools.LocalizedStrings.Get( "REQUIRED_FIELD_NOT_F" );

Please suggest here how to make the totalamount field as mandatory for one type of invoice.

Note:TotalAmount is single field in document def using for both the invoices.

Thanks in advance.



Was this article helpful?

0 out of 0 found this helpful


1 comment

  • Avatar
    Scott Chau

    I would remove Context.Field("TotalAmount").Value = false; since Value is expecting an actual value and not boolean.  

    Just add HasRuleError = true to set the field to error state.

    Keep in min, this just flags the field so you can stop in Verification but an operator can ignore the error and manually push it to the next stage.  


Please sign in to leave a comment.