Symptoms
When using the PO matching feature the issue with duplicated entries appears as on the screenshot below:
Cause
Since Purchase Order is a Repeating Group, FlexiCapture always tries to extract all possible values in the document. If you want to keep only the first value, you can just remove all unnecessary group instances. This could be done via a custom Event Handler or Script Stage.
Resolution
The following script will remove all instances except the first one:
if (Document.HasField("Invoice Layout\\PurchaseOrder"))
{
while (Document.Field("Invoice Layout\\PurchaseOrder").Items.Count>1)
{
int itemsCount = Document.Field("Invoice Layout\\PurchaseOrder").Items.Count;
Document.Field("Invoice Layout\\PurchaseOrder").Items.Delete(itemsCount-1);
}
}
Add the script to the Event Handler of the batch type settings or Project settings:
- In Project Setup Station open menu Project
- Choose one of the following options:
- Batch Type, select the batch type, and click Edit > Event handlers > After document state changed > Edit Script.
- Project > Project Properties > Event Handlers > After document state changed > Edit Script.
- Batch Type, select the batch type, and click Edit > Event handlers > After document state changed > Edit Script.
Note: The provided script is only for demonstration purposes and must be modified in accordance with the desired workflow.
Comments
2 comments
Jerry Rayburn
Hello! I am trying to perform this same action in my Invoice project to eliminate multiple Invoice Layout\\PurchaseOrder items.
I put the changes as shown in the example in the 'After Document State Changed' script but nothing changed when I went into a document definition and ran a Test. I then put the changes in the 'After Document Created' event and the project is still behaving the same and not deleting the extra 'Invoice Layout\\PurchaseOrder' items.
This is a test project and I have not Uploaded to Server because I was going to test first. I have also created a Test Batch but not seeing that this is working.
Do you have any suggestions?
NAGESHWAR PORLA
Hi Team,
I am getting above issue.
Please let me know the solution. How to fix the Duplicate PO's as well it is unnecessary recognize the Key word "Sales order No" treats as a Purchase order. How to ignore this Keyword.
Thanks and Regards,
Nageshwar Reddy Porla.
Please sign in to leave a comment.