Skip to content


Updating existing sales order

Boris asked 2 years ago
I\’m receiving \” Document does not exist, the Header cannot be updated\” error when changing a map to update if exists. I found the article from 2011 that states we either need to have 2 maps, one for original insert, the other for update, but I wanted to check if in that time the process has been improved and there is some way to make 1 map do both using logic?If the original issue still exists how would I make a calculated field to check if SOP Line exists or the SOP Header exists? Thanks
Patrick Roth Staff answered 2 years ago
You would have to set the Update If Exists flag on both the header & lines.
Yes you can determine this value at runtime vs hard coding the setting.
Couple of different ways you could do this:
1. use a multi data source map
Here you would query the SOP10100 table and then join it (or just a couple fields) to the source data.  So lets say you just return the SOP10100.CUSTNAME field only (because we don’t care about it, just need to see if it is empty or not)
Then in the calculation you create, you could then look at the field.  If it is empty, then the SOP Number doesn’t exist so you want to return 0.  If it has a value, then that means there was a SOP Number and the record exists so you return 0
if _CUSTNAME.Trim() = String.Empty then
  return 0
  return 1
end if
2. use a calculation (since you were going to create one anyway)
Here, we make a connection to SQL and run a query directly.  In the above, they get the 1099TYPE but you would just change the query.
So you could query the SOP10100 directly and use if exists() in the query to return 1 or 0.
Either will work fine, the multi ds map is a bit easier to understand and create but the query is probably the better route.

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