コミュニティ

At least one instance of repeatable group - PurchaseOrder - Flexicapture for Invoices

Hi All,

Does anyone know of a method for creating an error if there is not at least one instance of the repeating group 'PurchaseOrder' in Flexicapture for Invoices.

Tried loads of rule scripts, merge scripts etc but can't get anything to fire if the group is empty.

Thanks

Richard

この記事は役に立ちましたか?

0人中0人がこの記事が役に立ったと言っています

コメント

2件のコメント

  • Avatar
    Permanently deleted user
    Hello,

    Please try making a simple Document processing script containing this:
    if (Context.Field("PurchaseOrder").Items.Count==0)
    {
    Context.CheckSucceeded=false;
    Context.ErrorMessage="_something_";
    }



    Please let me know if you have any other questions or this solution doesn't work,
    Vladislav
    0
  • Avatar
    Permanently deleted user
    Hi Vladislav,

    Thanks for your response. Had seen this technique in vbscript in the example scripts in manual, like you I'd changed to C# and also borrowed some of the code from the existing scripts in the invoice document definition. So I had:


    if( Context.Field("PurchaseOrder").Items.Count == 0 )
    {
    Context.CheckSucceeded = false;
    Context.ErrorMessage = FCTools.LocalizedStrings.Get( "REQUIRED_FIELD_NOT_F" );
    }


    I then put 'Rejected' in the rule 'Tags' so that an error message would be generated in the 'Invoice Status' section of the data form.

    I applied this at the group level with only the group selected in 'Available Fields' and tested, didn't seem to work, then put the other fields from the group into the 'Available Fields' section and again didn't seem to work.

    The I went for this from the sample scripts:

    The rule is written for the checkmark group level. All the checkmarks in the group have been added to the list of fields included into the rule. The group itself has been excluded from the list.


    So took the group out of the 'Available Fields' and added the 'Order Number' field instead

    Changed the code to


    if( Context.Field("PurchaseOrder\\OrderNumber").Items.Count == 0 )
    {
    Context.CheckSucceeded = false;
    Context.ErrorMessage = FCTools.LocalizedStrings.Get( "REQUIRED_FIELD_NOT_F" );
    }


    Didn't like that, couldn't find the field.

    At last I found that


    if( Context.Field("PurchaseOrder").Items.Count == 0 )
    {
    Context.CheckSucceeded = false;
    Context.ErrorMessage = FCTools.LocalizedStrings.Get( "REQUIRED_FIELD_NOT_F" );
    }


    Works as expected if you put in a rule outside of the group, at the document level.

    Thanks again.

    Ricahard

    0

サインインしてコメントを残してください。