1

I tried to insert data to salesforce but it returns

Required fields are missing: [TopicId]

Here is my code in inserting the data:

$tObject = new Stdclass();
            $tObject->EntityId = 'Account salesforce id';
            $Object->TopicId = 'Topic salesforce id';

            $createResponse = $this->conn->create(array($tObject), 'TopicAssignment');
            var_dump($createResponse);

And in my .xml file:

<complexType name="TopicAssignment">
                <complexContent>
                    <extension base="ens:sObject">
                        <sequence>
                        <element name="CreatedBy" nillable="true" minOccurs="0" type="ens:User"/>
                        <element name="CreatedById" nillable="true" minOccurs="0" type="tns:ID"/>
                        <element name="CreatedDate" nillable="true" minOccurs="0" type="xsd:dateTime"/>
                        <element name="Entity" nillable="true" minOccurs="0" type="ens:sObject"/>
                        <element name="EntityId" nillable="true" minOccurs="0" type="tns:ID"/>
                        <element name="EntityKeyPrefix" nillable="true" minOccurs="0" type="xsd:string"/>
                        <element name="EntityType" nillable="true" minOccurs="0" type="xsd:string"/>
                        <element name="IsDeleted" nillable="true" minOccurs="0" type="xsd:boolean"/>
                        <element name="NetworkId" nillable="true" minOccurs="0" type="tns:ID"/>
                        <element name="SystemModstamp" nillable="true" minOccurs="0" type="xsd:dateTime"/>
                        <element name="Topic" nillable="true" minOccurs="0" type="ens:Topic"/>
                        <element name="TopicId" nillable="true" minOccurs="0" type="tns:ID"/>
                        </sequence>
                    </extension>
                </complexContent>
            </complexType>

Why does it return this error?

4
  • 1
    what is the values that are you sending? the TopicID should be filled and looks like that it was not.
    – m Peixoto
    Dec 9, 2019 at 14:07
  • It's a valid salesforce id from account. its just an example
    – sj_a
    Dec 9, 2019 at 14:12
  • Is the 3rd line in your provided code a typo, or is that how it actually appears in your code? Setting topicId on $Object instead of on $tObject would explain your issue.
    – Derek F
    Dec 9, 2019 at 14:28
  • Ohh!. .It fixed the problem, instead of $tObject I used $Object, thank you so much!
    – sj_a
    Dec 9, 2019 at 14:44

1 Answer 1

1

The issue here was just one of variable names.

The declared variable was $tObject
The line that set topicId was $Object->TopicId = 'value';
It should have been $tObject->TopicId = 'value';

Note that the incorrect version was missing the 't' at the start of the variable name.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .