如何从salesforce对象中删除数据?

时间:2017-08-28 09:27:15

标签: salesforce mule mule-esb

我有一个场景需要从Salesforce对象中删除完整数据。

首先,要获取该对象的所有ID,并将其保存在.csv格式的文件中。将数据上传到文件后,需要使用批处理中的记录删除记录。

我能够查询对象并将数据保存在.csv中,但删除数据有时会低于错误。

 Message               : null (java.nio.BufferUnderflowException).
    Element               : /batch-delete-genericFlow/processors/3 @ apl-sfa-batch-interface-v44:batch-delete-all.xml:48 (Transform Message)
    --------------------------------------------------------------------------------
    Exception stack is:
    null (java.nio.BufferUnderflowException). (org.mule.api.MessagingException)
      java.nio.Buffer.nextGetIndex(Buffer.java:500)
      java.nio.HeapCharBuffer.get(HeapCharBuffer.java:135)
      com.mulesoft.weave.reader.UTF8StreamSourceReader.decode$1(SeekableStreamSourceReader.scala:147)
      com.mulesoft.weave.reader.UTF8StreamSourceReader.read(SeekableStreamSourceReader.scala:167)
      com.mulesoft.weave.reader.csv.parser.StreamingCSVParser.read(StreamingCSVParser.scala:61)
      (66 more...)

      (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************

PFB删除批代码:

    <batch:job name="batch-delete-genericBatch" max-failed-records="-1">
        <batch:input>
            <enricher target="#[flowVars['jobInfo_delete']]" doc:name="Enricher jobId">
                <sfdc:create-job config-ref="SFA_MSBI" type="#[flowVars.sObjectName]" concurrencyMode="Serial" contentType="CSV" operation="delete" doc:name="Create Job"/>
            </enricher>
            <expression-component doc:name="Save Job ID"><![CDATA[sessionVars.jobInfo_delete = flowVars.jobInfo_delete.id
]]></expression-component>
        </batch:input>
        <batch:process-records>
            <batch:step name="Batch_Step" >
                <batch:commit  doc:name="Batch Commit" size="5000">
                    <processor-chain doc:name="Processor Chain">
                        <dw:transform-message metadata:id="df884737f2bc" doc:name="Transform Message">
                            <dw:set-payload><![CDATA[%dw 1.0
%output application/java
---
payload map {
    Id: $.Id
}]]></dw:set-payload>
                        </dw:transform-message>
                        <sfdc:create-batch config-ref="SFA_MSBI" doc:name="Salesforce">
                            <sfdc:job-info ref="#[flowVars.jobInfo_delete]"/>
                            <sfdc:objects ref="#[payload]"/>
                        </sfdc:create-batch>
                    </processor-chain>
                </batch:commit>
            </batch:step>
        </batch:process-records>
        <batch:on-complete>
            <async doc:name="Async">
                <sfdc:close-job config-ref="SFA_MSBI" jobId="#[sessionVars.jobInfo_delete]" doc:name="Salesforce"/>
            </async>

        </batch:on-complete>
    </batch:job>

请告知。

1 个答案:

答案 0 :(得分:0)

似乎错误导致某些值。 请发布更多代码以获得一些背景信息。 同时,以下是删除SFO的正确方法。

<sfdc:delete config-ref="mySalesforceConfig">
    <sfdc:ids>
        <sfdc:id>001...</sfdc:id>
    </sfdc:ids>
</sfdc:delete>

http://mulesoft.github.io/salesforce-connector/8.3.1/apidocs/apidoc.html#_delete