Skip to main content
Nov 18, 2014 3:01 PM UTC
Question

How to update an Opportunity via the SOAP API

Hey everybody,

My company utilizes Microsoft Dynamics CRM. The CRM instance pushes opportunity data into Marketo. From a separate application, I am trying to update the opportunity via the SOAP API, but having difficulty. I keep getting a response stating that the Opportunity is unchanged.
 

The id referenced in the request is captured by using getMObject in a previous request. My request using SyncMObjects looks like this:

$params = new \stdClass();

$mObj = new \stdClass();
$mObj->type = 'Opportunity';
$mObj->id = $id;

$attrib1 = new \stdClass();
$attrib1->name="Probability";
$attrib1->value="80%";

$attribList = array ($attrib1);

$costAttrib = new \stdClass();
$costAttrib->attrType="Tag";
$costAttrib->attrList = $attribList;

$mObj->typeAttribList= array($costAttrib);
$params->mObjectList = array($mObj);

$params->operation="UPDATE";

My response is this:
$success->result->mObjStatusList->mObjStatus->id=7923;
$success->result->mObjStatusList->mObjStatus->status="UNCHANGED";

I have tried a variety of different small changes, but keep getting the unchanged result. What am I missing? Am I missing a required attribute to update an opportunity?

Let me know when you can!

Thanks!
Phil Hotchkiss

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

4 replies

Nov 19, 2014 8:31 PM UTC
Can you please post the request XML this code generates?
Translate
Nov 19, 2014 9:23 PM UTC
I'm using PHP's SOAP client, but I believe it produces something like the following XML internally, I am only providing the information that would go inside the paramsSyncMObjects part of the SOAP message.

<mObjectList>
<mObject>
<type>Opportunity</type>
<id>7923</id>
<typeAttribList>
<typeAttrib>
<attrType>Tag</attrType>
<attrList>
<attrib>
<name>Probability</name>
<value>80%</value>
</Attrib>
</attrList>
</typeAttrib>
</typeAttribList>
</mObject>
</mObjectList>
<operation>UPDATE</operation>

Please let me know if you need more information.

Thanks!

Phil
 
Translate
Kenny_Elkington
Adobe Employee
Adobe Employee
Nov 19, 2014 9:41 PM UTC
Hi Phil,

the 'attrType' parameter is only valid when trying to update the Program object type, removing this should make it update normally.
Translate
Nov 19, 2014 10:12 PM UTC
Hey Kenny,

The request still went through, but I received the same response of $success->result->mObjStatusList->mObjStatus->id = 7923, and status of 'UNCHANGED'. Any other ideas?

Thanks!

Phil
Translate