Skip to content
+1-888-319-3663

COMMUNITY FORUM

Invoice Entity Lookup Failing

Mark asked 2 years ago
Hello all.
I have created a series of maps which take the invoices generated in CRM Field Service, posts them into holding tables in SQL, posts them into Dynamics GP and as the final step, updates the invoices in CRM Field Service to indicate that they have been posted.
Everything is working correctly until I do the last step.  For some reason, the lookup to the invoice entity is failing.  
The source data has the invoice guid, invoice number, processed flag and processed date (the invoice number and guid were read from CRM Field Service as the first step).  I then have a final step that selects the data where the processed flag is not set.  This data is being correctly selected.
I then use an entity lookup using the invoice number and update the eone_erptrxnumber field to the invoice number.  However, for some reason, instead of obtaining the invoice number and updating the existing invoice, it is creating a new invoice, with the invoice number being “Microsoft.Xrm.Sdk.EntityReference” and the correct invoice number being written to the eone_erptrxnumber field.  None of the invoices are getting updated correctly and I am having to manually delete this incorrect invoice.  Additionally, it is also failing the map as it says all invoices are duplicated (because it thinks every invoice number is “Microsoft.Xrm.Sdk.EntityReference”).
Here is the data that is being generated.  The first record should have the invoice number in the eone_erptrxnumber field, but it is getting left blank.  The second record is the incorrectly created invoice but the correct eone_erptrxnumber.
invoicenumber                                     eone_erptrxnumber                   eone_senttoerp
INV0001001                                                                                       True
Microsoft.Xrm.Sdk.EntityReference        INV0001001                             False
 
What am I doing wrong?
 
Answers
Ethan Sorenson Staff answered 2 years ago
Mark,
When you use an entity lookup or an entity reference, SmartConnect will lookup the guid for the record and pass that to CRM along with metadata specifying what entity it belongs to. So if you try to map an entity reference or an entity lookup to a string field you will see “Microsoft.Xrm.Sdk.EntityReference”. The correct way to use these fields is to map them to the unique identifier for the entity so the InvoiceId guid field. Then it will update the existing invoice with that guid.
Mark Fraser answered 2 years ago
Thanks Ethan.  I knew I was making a stupid mistake.  However, I now have a different error.
Although I have ticked the option to update existing records, it is trying to insert a new record and is coming up with “Cannot insert duplicate key” errors on every invoice.  I have also tried the ignore duplication errors but that doesn’t help either.  Am I making another stupid mistake?

If you would like to submit an answer or comment, please sign in to the eOne portal.