Stwissel / node-red-contrib-salesforce

A set of Node-RED nodes to interact with Salesforce and Force.com
MIT License
10 stars 17 forks source link

I am having issues performing an update, since it automatically runs case assignment rules. #21

Closed ohgodbees closed 5 years ago

ohgodbees commented 6 years ago

Is there a way to pass custom headers through to nforce? I am having an issue where if I send even the simplest update:

msg.payload = { id: "XXXXXXXXXXXXXXX", Subject: "TEST - please ignore me" };
return msg;

The update takes place correctly, but the case is then reassigned to the default queue.

I believe I am running into this issue:

https://success.salesforce.com/ideaView?id=08730000000jjoPAAQ

..and that I need to set 'SForce-Auto-Assign: FALSE' in the headers, but I don't see a way to pass custom headers even though it appears nforce supports them:

https://github.com/kevinohara80/nforce

var headers = {
  'sforce-auto-assign': '1'
};

org.insert({ oauth: oauth, sobject: so, headers: headers }, function(err, record) {
  // callback
});

Is it possible to do this?

In the meantime, I'm going to revert back to curl and confirm that passing the headers resolves my issue.

Thank you!

Stwissel commented 6 years ago

I presume you refer to the DML module? What headers would you need?

ohgodbees commented 6 years ago

Sorry, yes I mean the DML module.

So it looks like I am only missing this header:

SForce-Auto-Assign: FALSE

(https://developer.salesforce.com/docs/atlas.en-us.214.0.api_rest.meta/api_rest/headers_autoassign.htm)

I was able to reproduce the issue with cURL, by configuring my Sandbox to behave the same way as the Production environment (where assignment rules apply by default), and when I update a Case record without this header, it will re-assign the Case to the default queue. When the header is added in, it stays assigned to the existing owner.

curl https://***instance***.salesforce.com/services/data/v30.0/sobjects/Case/XXXXXXXXXXXXXXX -H 'Authorization: Bearer ***access token***' -H 'SForce-Auto-Assign: FALSE' -H 'X-PrettyPrint:1' -H 'Content-Type: application/json' --data-binary @blah.json -X PATCH

blah.json contains this:

{
          "Description": "TEST - edit 10"
}
Stwissel commented 6 years ago

Got it. Will add that capability in the next release

Stwissel commented 5 years ago

Added in 0.6. If you provide msg.sf.headers that object gets added to the payload as header element