Salesforce Opportunity ID not being passed after a PostResponseMap Hook

I am originally exporting from SF, updating NS and updating back to SF, As long as I don't include the PostSubmit Hook everything works great,  once I add the hook it seems to be unable to find the Opportunity ID and therefore errors. Any ideas on why this ID is getting lost would be much appreciated. 

Error:

"Unable to find lookup value for Salesforce Opportunity field \"Id\" given the query conditions \"(Id = null)\""

 

ScreenShots:

Import Map Connection

Hook Location

Hook JS:

I even tried to bring in the opportunity ID in the hook and pass to the import connection.

Thank you!

0

Comments

9 comments
Date Votes
  • Hey David,

    What's the output if you hit Preview?

    Thanks,
    -Lucian

    0
  • Hey Lucian,

      None of the fields get populated.  Where as before putting the hook in it would populate all fields green, with correct information.

    0
  • Hey David,

    Yeah, I don't think that postResponseMapData is an actual variable. So you're returning blank data. (Edit: this is the right variable)

    I'd start a new script and insert the postSubmit stub function. Hit Preview and look at the output that you get. It should include an ID, code, etc.. Then, start doing your transformation but make sure that you still have all those same fields (id, code) in the output. The hook is expecting data the data to have that particular structure.

    Does that make sense?

    0
  • It does make sense in theory,  in practice I get a little twisted around. 

    It almost seems like a tug of war, on one hand when I use responseData I do not get the correct error responses, and it requires me to put in postResponseMapData. Perhaps a little more practice is in order, but I appreciate your response. Basically the data is not getting passed because of the variable. 

     

    0
  • Well ultimately, the issue is that the output is not formatted how the tool is expecting. Actually after taking a second look, I think that postReponseMapData is the correct variable. You just need to make sure that your output matches the format that the initial postResponse stub creates, i.e. an array where each object has an "id" field.

    0
  • I am not sure what the missing piece is.

    The retry data clearly has the field that is matched on. 

    0
  • Hey David,

    You've introduced an extra level in your object there. The key would now be "responsedata.OpportunityId".

    Again, if you look at the preview output of just the stub function you'll see that it doesn't match.

    Your retry data should just look like:

    {
    "Item": [{...}],
    "OpportunityId": "bla",
    ...
    }

    Note that there's no top-level "responsedata" key.

    Don't hold me to this, but I think if you just got rid of your final map (lines 64-68) and made it just:

    return options.postResponseMapData;

    Then I believe it'll work.

    0
  • You were 100% correct.  That makes so much sense now. Thank you very much for the help!

    This sure caused a pretty massive headache, so thank you!

    0
  • Awesome, I'm glad that worked!

    0

Please sign in to leave a comment.

 

Didn't find what you were looking for?

New post