0
votes

I am facing issue while inserting record in salesforce. Type of record is lookup(Account) and field name is site_id.I insert csv file record into salesforce. But because of this record(data type(lookup)) i can not insert record in salesforce. If I change type of record to Text than i can insert. But I need lookup(Account) type. How is it possible ...please help me

following is my flow

<batch:job name="testsalesforceBatch1">
        <batch:input>
            <file:inbound-endpoint path="CustomFile" responseTimeout="10000" doc:name="File"/>
            <data-mapper:transform config-ref="CSV_To_List_Report__c__1" doc:name="CSV To List&lt;Report__c&gt;"/>
        </batch:input>
        <batch:process-records>
            <batch:step name="Batch_Step">
                <batch:commit size="1000" doc:name="Batch Commit">
                    <sfdc:create-bulk config-ref="Salesforce" type="Report__c" doc:name="Salesforce">
                        <sfdc:objects ref="#[payload]"/>
                    </sfdc:create-bulk>
                </batch:commit>
            </batch:step>
        </batch:process-records>
        <batch:on-complete>
            <logger message="#[payload.totalRecords]" level="INFO" doc:name="Logger"/>
        </batch:on-complete>
    </batch:job>

I got following error...

 [SaveResult  errors='{[1][Error  fields='{XXXXXXX,}'
 message='XXXXXX: id value of incorrect type: 000'
 statusCode='MALFORMED_ID'
]

NOTE: 000 value is available in Account table

2
can any one help me?user3855589

2 Answers

0
votes

I got answer..how to insert lookup data type record in salesforce through mule. Use recordId to store that value...

Thanks

0
votes

For Salesforce Integrations there are two ways to insert/upsert/create fields with lookup values.

Way 1: Use the actual ID of the lookup target. So if you are going to lookup an Account, you first need to get the ID of the Account you are targeting, then use that ID in the field as a "String" in data mapper.

Way 2: Use a External ID on Account and upsert the new record referring to the external ID. This is a little more complicated but is very excellent way to not have to do two API calls. In Datamapper then, you need to have Account be listed as an Element and not as an Attribute. This has to be done manually as Datamapper won't know to do this on its own.

Account (Element)
|-type (String)  -> 'Account'  *this is just a fixed string*
|-ExternalIdFieldName__c (String) -> external_id_from_datasource

Since Account is a standard SalesForce object it doesn't have a __c or __r after it, if it was a custom object and you are doing a lookup it changes a little bit.

Objects:

MyCustomAccount__c
External ID in above: AccountExternalId__c
Lookup field:  AccountLookup__c  (lookup to Account from Contact)

In Datamapper then you have:

AccountLookup__r  (Element)  *notice the __r instead of __c*
|- type (String) -> 'MyCustomAccount__c'  *this is just a fixed string*
|- AccountExternalId__c (String) -> externalidfieldfromcsv