function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
jkyrohonkajkyrohonka 

Batch delete

Hi,

Could someone give a hint to why the following SOAP batch delete
call returns an error. What I would like to is to delete several
tasks (or accounts.. etc.).

The error is 1208, 'batch arguments 0 must be struct'
(inside an array, one error for both the first ("batch arguments 0")
and the second ("batch arguments 1") input array)

<?xml version="1.1" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"
 xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
 xmlns:xsd="http://www.w3.org/1999/XMLSchema"
 xmlns:tns="salesforce"
 xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">

 <s:Header>
  <tns:headerStruct>
   <session_id xsi:type='xsd:string'> . . . </session_id>
   <version xsi:type='xsd:string'>2.0</version>
  </tns:headerStruct>
 </s:Header>

 <s:Body>
  <m:batch xmlns:m='sfconnector:SalesforceConnector'>

   <type xsi:type='xsd:string'>task</type>
   <operation xsi:type='xsd:string'>delete<operation>

   <arguments xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="xsd:anyType[2]">

    <value xsi:type='SOAP-ENC:Array'SOAP-ENC:arrayType="xsd:string[1]">
     <id xsi:type='xsd:string'>00T30000...</id>
    </value>

    <value xsi:type='SOAP-ENC:Array'SOAP-ENC:arrayType="xsd:string[1]">
     <id xsi:type='xsd:string'>00T30000...</id>
    </value>

   </arguments>

  </m:batch>
 </s:Body>

</s:Envelope>


There is the 'operation' member, and the 'arguments' member is an array with
two sub-arrays, one for each task to be deleted. Each sub-array contains a
single 'id' member.

The documentation says to use an array of structs or a maps that contain a
single 'id' member for each target of a batch delete, if I understood
correctly.

What actually are the differences between an array, a struct and a map from
the sforce point of view?


Thank you,

 Jussi

jkyrohonkajkyrohonka

Hi,

I guess it will be possible to delete multiple objects in the coming version of the API.

I would still like to know the reason the abovementioned batch delete failed.

I interpreted that the 'argumetns' parameter for the batch call is an array with structs or maps as its elements. For batch insert or modify, the sub-arrays would be like the 'record' parameters for the corresponding API calls. For batch delete, the sub-arrays would be arrays with just one element, that is, the id of the object that is to be deleted. The idea in the above batch deletion was to delete two tasks.

The return is a structure: (simplified)

    1208   batch arguments 0 must be struct       1208   batch arguments 1 must be struct  

 

jkyrohonkajkyrohonka

Oops, that message form is dangerous.. This is what I was about to say:

---------------

Hi,

I guess it will be possible to delete multiple objects in the coming version of the API.

I would still like to know the reason the abovementioned batch delete failed.

I interpreted that the 'argumetns' parameter for the batch call is an array with structs or maps as its elements. For batch insert or modify, the sub-arrays would be like the 'record' parameters for the corresponding API calls. For batch delete, the sub-arrays would be arrays with just one element, that is, the id of the object that is to be deleted. The idea in the above batch deletion was to delete two tasks.

The resulting reply is a structure: (simplified)

<value>
 <valueArray>
  <value>1208</value>
  <value>batch arguments 0 must be struct</value>
 </valueArray>
 <valueArray>
  <value>1208</value>
  <value>batch arguments 1 must be struct</value>
 </valueArray>
<value>

That is, an error for both of the deletion.

I just can't spot the error.

--
Jussi

DevAngelDevAngel

Hi jkyrohonka,

Here is a sample batch insert, you should be able to get to a batch delete from here.  Since you are using SOAP, I highly recommend API 2.5 as it is based on all CRUD calls being batch.

  <soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
    <q1:batch xmlns:q1="sfconnector:SalesforceConnector">
      <type xsi:type="xsd:string">account</type>
      <operation xsi:type="xsd:string">insert</operation>
      <arguments href="#id1" />
    </q1:batch>
    <soapenc:Array id="id1" soapenc:arrayType="xsd:anyType[3]">

<!--array of 3 records to insert not the type above-->
      <Item href="#id2" />
      <Item href="#id3" />
      <Item href="#id4" />
    </soapenc:Array>

<!--these are the three records to insert -->
    <soapenc:Array id="id2" soapenc:arrayType="tns:mapEntry[2]">
      <Item href="#id5" />
      <Item href="#id6" />
    </soapenc:Array>
    <soapenc:Array id="id3" soapenc:arrayType="tns:mapEntry[2]">
      <Item href="#id7" />
      <Item href="#id8" />
    </soapenc:Array>
    <soapenc:Array id="id4" soapenc:arrayType="tns:mapEntry[2]">
      <Item href="#id9" />
      <Item href="#id10" />
    </soapenc:Array>

<!--for delete I guess you only need one field, that holds the ID, for each argument-->
    <tns:mapEntry id="id5" xsi:type="tns:mapEntry">
      <key xsi:type="xsd:string">name</key>
      <value xsi:type="xsd:string">newaccount 1</value>
    </tns:mapEntry>
    <tns:mapEntry id="id6" xsi:type="tns:mapEntry">
      <key xsi:type="xsd:string">url</key>
      <value xsi:type="xsd:string">www.url1.com</value>
    </tns:mapEntry>
    <tns:mapEntry id="id7" xsi:type="tns:mapEntry">
      <key xsi:type="xsd:string">name</key>
      <value xsi:type="xsd:string">newaccount 2</value>
    </tns:mapEntry>
    <tns:mapEntry id="id8" xsi:type="tns:mapEntry">
      <key xsi:type="xsd:string">url</key>
      <value xsi:type="xsd:string">www.url2.com</value>
    </tns:mapEntry>
    <tns:mapEntry id="id9" xsi:type="tns:mapEntry">
      <key xsi:type="xsd:string">name</key>
      <value xsi:type="xsd:string">newaccount 3</value>
    </tns:mapEntry>
    <tns:mapEntry id="id10" xsi:type="tns:mapEntry">
      <key xsi:type="xsd:string">url</key>
      <value xsi:type="xsd:string">www.url3.com</value>
    </tns:mapEntry>
  </soap:Body>

jkyrohonkajkyrohonka

Ok, thanks. I had tried a couple of different variations, but I guess I'll be able to figure it out.

Just wanted to try and understand what went wrong.

--
Jussi