I am upserting records to a object in salesforce using SFDC connector using oauth username and password. I am using external Id(say ext_Id__c) for this operation. Consider a object name as order. There is a field say 'merchant__c' which is a relational field referring to Account Id(which has a external field acc_ext_Id__c).
Now my requirement is to update merchant__c field using acc_ext_Id__c value. I need to do using Mule Salesforce connector.
I tried workbench rest explorer, using the below request I am able to update the record
{
"merchant__r": {"acc_ext_Id__c" : "test"}
}
I tried to create same using dataweave
%dw 2.0
output application/java
---
[{
"merchant__r": {"acc_ext_Id__c" : "test"}
}]
But it was throwing an error
com.sforce.soap.partner.fault.InvalidSObjectFault: null
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_265]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:1.8.0_265]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.8.0_265]
at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[?:1.8.0_265]
at java.lang.Class.newInstance(Class.java:442) ~[?:1.8.0_265]
at com.sforce.ws.bind.TypeMapper.readSingle(TypeMapper.java:721) ~[force-wsc-50.0.0.jar:?]
at com.sforce.ws.bind.TypeMapper.readObject(TypeMapper.java:593) ~[force-wsc-50.0.0.jar:?]
at com.sforce.ws.transport.SoapConnection.parseDetail(SoapConnection.java:250) ~[force-wsc-50.0.0.jar:?]
at com.sforce.ws.transport.SoapConnection.createException(SoapConnection.java:224) ~[force-wsc-50.0.0.jar:?]
at com.sforce.ws.transport.SoapConnection.receive(SoapConnection.java:163) ~[force-wsc-50.0.0.jar:?]
at com.sforce.ws.transport.SoapConnection.send(SoapConnection.java:108) ~[force-wsc-50.0.0.jar:?]
at com.sforce.soap.partner.PartnerConnection.update(PartnerConnection.java:865) ~[force-partner-api-50.0.0.jar:?]
at org.mule.extension.salesforce.internal.service.CoreServiceImpl.lambda$update$2(CoreServiceImpl.java:154) ~[mule-salesforce-connector-10.7.0-mule-plugin.jar:?]
at org.mule.extension.salesforce.internal.connection.ForceWSCConnection.executeOverPartnerClient(ForceWSCConnection.java:264) ~[mule-salesforce-connector-10.7.0-mule-plugin.jar:?]
at org.mule.extension.salesforce.internal.service.ForceWSCService.executeOverPartnerClient(ForceWSCService.java:24) ~[mule-salesforce-connector-10.7.0-mule-plugin.jar:?]
at org.mule.extension.salesforce.internal.service.CoreServiceImpl.update(CoreServiceImpl.java:154) ~[mule-salesforce-connector-10.7.0-mule-plugin.jar:?]
at org.mule.extension.salesforce.internal.operation.core.UpdateOperation.update(UpdateOperation.java:56) ~[mule-salesforce-connector-10.7.0-mule-plugin.jar:?]
at org.mule.extension.salesforce.internal.operation.core.UpdateOperation$update$MethodComponentExecutor.execute(Unknown Source) ~[?:?]
at org.mule.runtime.module.extension.internal.runtime.execution.GeneratedMethodComponentExecutor.execute(GeneratedMethodComponentExecutor.java:97) ~[mule-module-extensions-support-4.3.0-20210119.jar:4.3.0-20210119]
at org.mule.runtime.module.extension.internal.runtime.execution.CompletableMethodOperationExecutor.doExecute(CompletableMethodOperationExecutor.java:29) ~[mule-module-extensions-support-4.3.0-20210119.jar:4.3.0-20210119]
at org.mule.runtime.module.extension.internal.runtime.execution.AbstractCompletableMethodOperationExecutor.execute(AbstractCompletableMethodOperationExecutor.java:63) ~[mule-module-extensions-support-4.3.0-20210119.jar:4.3.0-20210119]
at org.mule.runtime.module.extension.internal.runtime.operation.DefaultExecutionMediator.executeCommand(DefaultExecutionMediator.java:211) ~[mule-module-extensions-support-4.3.0-20210119.jar:4.3.0-20210119]
at org.mule.runtime.module.extension.internal.runtime.operation.DefaultExecutionMediator.executeWithInterceptors(DefaultExecutionMediator.java:194) ~[mule-module-extensions-support-4.3.0-20210119.jar:4.3.0-20210119]
at org.mule.runtime.module.extension.internal.runtime.operation.DefaultExecutionMediator.lambda$execute$1(DefaultExecutionMediator.java:113) ~[mule-module-extensions-support-4.3.0-20210119.jar:4.3.0-20210119]
at org.mule.runtime.module.extension.internal.runtime.operation.DefaultExecutionMediator.lambda$new$0(DefaultExecutionMediator.java:61) ~[mule-module-extensions-support-4.3.0-20210119.jar:4.3.0-20210119]
at org.mule.runtime.module.extension.internal.runtime.operation.DefaultExecutionMediator.execute(DefaultExecutionMediator.java:112) ~[mule-module-extensions-support-4.3.0-20210119.jar:4.3.0-20210119]
at org.mule.runtime.module.extension.internal.runtime.operation.ComponentMessageProcessor.executeOperation(ComponentMessageProcessor.java:563) ~[mule-module-extensions-support-4.3.0-20210119.jar:4.3.0-20210119]
at org.mule.runtime.module.extension.internal.runtime.operation.OAuthOperationMessageProcessor.executeOperation(OAuthOperationMessageProcessor.java:58) ~[mule-module-extensions-support-4.3.0-20210119.jar:4.3.0-20210119]
at org.mule.runtime.module.extension.internal.runtime.operation.ComponentMessageProcessor.prepareAndExecuteOperation(ComponentMessageProcessor.java:765) ~[mule-module-extensions-support-4.3.0-20210119.jar:4.3.0-20210119]
at org.mule.runtime.module.extension.internal.runtime.operation.ComponentMessageProcessor.lambda$onEventSynchronous$19(ComponentMessageProcessor.java:465) ~[mule-module-extensions-support-4.3.0-20210119.jar:4.3.0-20210119]
at org.mule.runtime.module.extension.internal.runtime.operation.ComponentMessageProcessor.onEventSynchronous(ComponentMessageProcessor.java:472) ~[mule-module-extensions-support-4.3.0-20210119.jar:4.3.0-20210119]
at org.mule.runtime.module.extension.internal.runtime.operation.ComponentMessageProcessor.lambda$null$9(ComponentMessageProcessor.java:380) ~[mule-module-extensions-support-4.3.0-20210119.jar:4.3.0-20210119]
at reactor.core.publisher.FluxPeekFuseable$PeekFuseableConditionalSubscriber.onNext(FluxPeekFuseable.java:482) [reactor-core-3.2.12.RELEASE.jar:3.2.12.RELEASE]
at reactor.core.publisher.FluxMapFuseable$MapFuseableConditionalSubscriber.onNext(FluxMapFuseable.java:287) [reactor-core-3.2.12.RELEASE.jar:3.2.12.RELEASE]
at reactor.core.publisher.FluxPeekFuseable$PeekFuseableConditionalSubscriber.onNext(FluxPeekFuseable.java:496) [reactor-core-3.2.12.RELEASE.jar:3.2.12.RELEASE]
at org.mule.runtime.core.privileged.processor.chain.AbstractMessageProcessorChain$2.onNext(AbstractMessageProcessorChain.java:430) [mule-core-4.3.0-20210119.jar:4.3.0-20210119]
at org.mule.runtime.core.privileged.processor.chain.AbstractMessageProcessorChain$2.onNext(AbstractMessageProcessorChain.java:425) [mule-core-4.3.0-20210119.jar:4.3.0-20210119]
at reactor.core.publisher.FluxHide$SuppressFuseableSubscriber.onNext(FluxHide.java:127) [reactor-core-3.2.12.RELEASE.jar:3.2.12.RELEASE]
at reactor.core.publisher.FluxPeekFuseable$PeekFuseableSubscriber.onNext(FluxPeekFuseable.java:204) [reactor-core-3.2.12.RELEASE.jar:3.2.12.RELEASE]
at reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onNext(FluxOnAssembly.java:345) [reactor-core-3.2.12.RELEASE.jar:3.2.12.RELEASE]
at reactor.core.publisher.FluxSubscribeOnValue$ScheduledScalar.run(FluxSubscribeOnValue.java:178) [reactor-core-3.2.12.RELEASE.jar:3.2.12.RELEASE]
at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:50) [reactor-core-3.2.12.RELEASE.jar:3.2.12.RELEASE]
at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:27) [reactor-core-3.2.12.RELEASE.jar:3.2.12.RELEASE]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_265]
at org.mule.service.scheduler.internal.AbstractRunnableFutureDecorator.doRun(AbstractRunnableFutureDecorator.java:111) [mule-service-scheduler-1.3.2/:?]
at org.mule.service.scheduler.internal.RunnableFutureDecorator.run(RunnableFutureDecorator.java:54) [mule-service-scheduler-1.3.2/:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_265]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_265]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_265]
ERROR 2021-03-24 21:45:14,082 [[MuleRuntime].uber.20: [test].testFlow.BLOCKING @407540e] [processor: ; event: 193ef9f1-8cbc-11eb-a48f-8c04ba3265ac] org.mule.runtime.core.internal.exception.OnErrorPropagateHandler:
How to send the request to SFDC to get it updated corerectly?
It looks like there is a difference between the workbench test and the DataWeave script. In the first case you are showing an object, while the DataWeave script is creating an array with an object.
Have you tried sending just the object (ie without the square brackets)?
Example: