July 31, 2023

tSalesforceOutput – Docs for ESB Sales Force 7.x

tSalesforceOutput

Inserts, updates, upserts, or deletes data in a Salesforce object.

tSalesforceOutput Standard properties

These properties are used to configure tSalesforceOutput running
in the Standard Job framework.

The Standard
tSalesforceOutput component belongs to the Business and the Cloud families.

The component in this framework is available in all Talend
products
.

Basic settings

Property Type

Select the way the connection details
will be set.

  • Built-In: The connection details will be set
    locally for this component. You need to specify the values for all
    related connection properties manually.

  • Repository: The connection details stored
    centrally in Repository > Metadata will be reused by this component. You need to click
    the […] button next to it and in the pop-up
    Repository Content dialog box, select the
    connection details to be reused, and all related connection
    properties will be automatically filled in.

This property is not available when other connection component is selected
from the Connection Component drop-down list.

Connection Component

Select the component that opens the database connection to be reused by this
component.

Connection type

Select the type of the connection from the drop-down list. The
connection properties will vary according to the connection type you choose.

  • Basic: select this option to
    access Salesforce by entering your Salesforce username and password.

  • OAuth: select this option to
    access Salesforce using OAuth (Open Authorization) 2.0 protocol to authenticate the
    user. From the Oauth2 flow type drop-down
    list displayed, you need to choose an OAuth 2.0 authentication flow type, either
    Json Web Token Flow or Implicit Flow (Deprecated) (User Agent Flow). This
    way, you need to create a connected app in Salesforce to configure a Salesforce
    authentication provider.

    For more information about the OAuth authentication flow, see Authenticate Apps with OAuth.

    For more information about how to create a connected app in
    Salesforce, see Create a Connected App.

User Id

The Salesforce username.

This property is available
only when the Basic connection type is selected.

Password

The Salesforce password associated with the username.

This property is available
only when the Basic connection type is selected.

Security Token

The Salesforce security token. For more information, see Reset Your Security Token.

This property is available
only when the Basic connection type is selected.

Issuer

The OAuth Consumer Key, generated
when your connected app is created and shown in the connected app detail page in
Salesforce. For more information, see Create a Connected App.

This property is available only
when the OAuth Json Web Token Flow type is selected.

Subject

The Salesforce username.

This property is available only
when the OAuth Json Web Token Flow type is selected.

Audience

Json Web Token audience.

You can set your own Json Web Token
audience.

This property is available only
when OAuth is selected from the Connection type
drop-down list and Json Web Token Flow is selected from the the
Oauth2 flow type drop-down list.

Expiration time (in seconds)

The expiration time of the assertion (in seconds) within five
minutes.

This property is available only
when the OAuth Json Web Token Flow type is selected.

Key store

The path to the keystore file in Java Keystore (JKS) format.

The keystore file can be generated by creating a certificate signed by
Salesforce and then exporting it to keystore. For more information, see Generate a Self-Signed Certificate.

This property is available only
when the OAuth Json Web Token Flow type is selected.

Key store password

The keystore password.

This property is available only
when the OAuth Json Web Token Flow type is selected.

Certificate alias

The unique name of the certificate signed by Salesforce.

This property is available only
when the OAuth Json Web Token Flow type is selected.

Client Id

The OAuth Consumer Key, generated
when your connected app is created and shown in the connected app detail page in
Salesforce. For more information, see Create a Connected App.

This property is available
only when the OAuth Implicit Flow type is selected.

Client Secret

The OAuth Consumer Secret, generated when your connected app is
created and shown in the connected app detail page in Salesforce. For more information,
see Create a Connected App.

This property is available
only when the OAuth Implicit Flow type is selected.

Callback Host

The host value in the OAuth authentication callback URL that is
defined during the creation of a connected app and will be shown in the API (Enable OAuth Settings) area of the connected app
detail page in Salesforce.

This property is available
only when the OAuth Implicit Flow type is selected.

Callback Port

The port value in the OAuth authentication callback URL that is
defined during the creation of a connected app and will be shown in the API (Enable OAuth Settings) area of the connected app
detail page in Salesforce.

This property is available
only when the OAuth Implicit Flow type is selected.

Token File

The path to the token file that stores the refresh token used to get
the access token without authorization.

This property is available
only when the OAuth Implicit Flow type is selected.

Module Name

Click the […] button next to
the field and in the dialog box displayed, select the module that will be used or select
the Use custom object check box and specify the
module name in the Object Name field.

Schema and Edit schema

A schema is a row description. It defines the number of fields
(columns) to be processed and passed on to the next component. When you create a Spark
Job, avoid the reserved word line when naming the
fields.

Click Edit
schema
to make changes to the schema. If the current schema is of the Repository type, three options are available:

  • View schema: choose this
    option to view the schema only.

  • Change to built-in property:
    choose this option to change the schema to Built-in for local changes.

  • Update repository connection:
    choose this option to change the schema stored in the repository and decide whether
    to propagate the changes to all the Jobs upon completion. If you just want to
    propagate the changes to the current Job, you can select No upon completion and choose this schema metadata
    again in the Repository Content
    window.

Click Sync
columns
to retrieve the schema from the previous component connected in the
Job.

This
component offers the advantage of the dynamic schema feature. This allows you to
retrieve unknown columns from source files or to copy batches of columns from a source
without mapping each column individually. For further information about dynamic schemas,
see
Talend Studio

User Guide.

This dynamic schema feature is designed for the purpose of
retrieving unknown columns of a module and is recommended to be used for this purpose only; it
is not recommended for the use of creating modules.

Output Action

Select one of the following operations to be performed from the
drop-down list.

  • INSERT: insert one or more
    new records into Salesforce.

  • UPDATE: update one or more
    existing records in Salesforce.

  • UPSERT: create new records
    or update existing records. In the Upsert Key
    Column
    field displayed, specify the key column for the upsert
    operation. By selecting Output upsert column, a column named
    UpsertColumnValue will be added to the output schema. The
    column holds upsert key values and thus can be used to monitor the upsert key. You
    can select Output upsert column if the upsert key is a
    variable.

  • DELETE: delete one or more
    records in Salesforce.

Advanced settings

Salesforce URL

The Webservice URL required to connect to Salesforce.

API version

The Salesforce API version.

This property is available only when the
OAuth connection type is selected.

Use or save the connection
session

Select this check box and in the Session
directory
field displayed, specify the path to the connection session file
to be saved or used.

This session file can be shared by different Jobs to retrieve a
connection session as long as the correct user ID is provided by the component. This
way, you do not need to connect to the server to retrieve the session.

When an expired session is detected, if the correct connection
information (the user ID, password, and security key) is provided, the component will
connect to the server to retrieve the new session information and update the connection
session file.

This property is available
only when the Basic connection type is selected.

Need compression

Select this check box to activate SOAP message compression, which can
result in increased performance levels.

Use Http Chunked

Select this check box to use the
HTTP chunked data transfer mechanism.

Client Id

Enter the ID of the real user to differentiate between those who use
the same account and password to access the Salesforce website.

Timeout

Enter the intended number of query timeout in milliseconds in
Salesforce.

Use Proxy

Select this check box to use a proxy server, and in the Host, Port,
User Id, and Password fields displayed, specify the connection parameters of the proxy
server.

Relationship mapping for
upsert

Click the
[+] button to add lines as needed and specify
the external ID fields in the input flow, the lookup relationship fields in the upsert
module, the lookup module as well as the external ID fields in the lookup module.

  • Column name of Talend Schema:
    the name of the external ID field in the input flow. It refers to the fields in the
    schema of the preceding component. Such columns are intended to match against the
    external ID fields specified in the External id
    name
    column, which are the fields of the lookup module specified in the
    Module name column.

  • Lookup field name: the name of the lookup
    field. It refers to the lookup field of the module specified in the Module Name field in the Basic settings view. This column needs to be specified when there are
    NULL input values for it and the Ignore Null
    check box is cleared.

  • Lookup relationship field name:
    the name of the lookup relationship field. It refers to the lookup relationship fields
    of the module specified in the Module Name field
    in the Basic settings view and is intended to
    establish relationship with the lookup module specified in the Module name column in this table. For how to define the
    lookup relationship fields and how to provide their correct names in the Lookup relationship field name field, go to the
    Salesforce website and launch the Salesforce Data Loader application for proper actions
    and information.

  • Module name: the name of the lookup module.

  • External id name: the name of the external ID
    field in the lookup module specified in the Module
    name
    column.

This property is
available only when UPSERT is selected from the
Output Action drop-down list.

Extend Insert

Select this check box to transfer the output data in batches.
In the Commit Level field displayed,
specify the number of lines per batch.

Die on Error

Select the check box to stop the execution of the Job when an error
occurs.

This check box is cleared by default, meaning to skip the row on error and to
complete the process for error-free rows.

Retrieve Id

Select this check box to allow Salesforce to return the
Salesforce ID for the inserted or updated records.

This check box is available only when
INSERT or UPSERT is selected
from the Output Action drop-down list
and the Extend Insert check box is
cleared.

When this check box is selected and the
tSalesforceOutput component is linked to another
component via a Row > Main connection, the following column(s) will be added to the schema
of the data flow:

  • salesforce_id: the Salesforce ID of the created or
    updated record.

  • salesforce_upsert_status (only for
    UPSERT): the status of the upsert action to
    indicate whether the record is created or updated.

Ignore Null

Select this check box to ignore NULL values.

This property
is available only when UPDATE or UPSERT is selected from the Output
Action
drop-down list.

Log File Name

Specify the path to the log file that holds all error logs.

tStatCatcher Statistics

Select this check box to gather the Job processing metadata at the Job level
as well as at each component level.

Global Variables

NB_LINE

The number of rows processed. This is an After variable and it returns an integer.

NB_SUCCESS

The number of rows successfully processed. This is an After variable and it returns an
integer.

NB_REJECT

The number of rows rejected. This is an After variable and it returns an integer.

ERROR_MESSAGE

The error message generated by the component when an error occurs. This is an After
variable and it returns a string.

Usage

Usage rule

This component can be used as an end
component or an intermediate component of a Job or subJob and it always needs an input
link.

Upserting Salesforce data based on external IDs

Here is an example of using Talend components to insert and update Salesforce Contact object data based on the mapping
relationship with external IDs of the Account object.

The Job used in this example is composed of the following seven subJobs:

  • the first subJob opens a connection to Salesforce,

  • the second subJob deletes some Account records based on external IDs,

  • the third subJob inserts two Account records with external IDs,

  • the fourth subJob inserts three Contact records based on the mapping relationship with
    the Account object external IDs, and gathers both inserted and erroneous data,

  • the fifth subJob updates two inserted Contact records based on the mapping relationship
    with the Account object external IDs,

  • the sixth subJob retrieves the inserted Accout records, and

  • the seventh subJob retrieves the upserted Contact records.

tSalesforceOutput_1.png

Creating a Job for upserting Salesforce data based on external IDs

  • An external ID custom field Account_External_ID has
    been added for the Account object in your Salesforce, which will be used to
    map the relationship with the Contact object.

    tSalesforceOutput_2.png
  • An external ID custom field Contact_Talend_ID has been
    added for the Contact object in Salesforce, which will be used as the key
    column for upserting Contact object data.

    tSalesforceOutput_3.png
  1. Create a new Job and add a tSalesforceConnection
    component, three tSalesforceInput components, four
    tSalesforceOutput components, three
    tFixedFlowInput components, and four
    tLogRow components.
  2. Connect the first tSalesforceInput component to the
    first tSalelsforceOutput component using a Row > Main connection.
  3. Do the same to connect the first tFixedFlowInput
    component to the second tSalesforceOutput component, the
    second tFixedFlowInput component to the third
    tSalesforceOutput component, the third
    tFixedFlowInput component to the fourth
    tSalesforceOutput component, the second
    tSalesforceInput component to the third
    tLogRow component, and the third
    tSalesforceInput component to the fourth
    tLogRow component.
  4. Connect the third tSalesforceOutput component to the
    first tLogRow component using a Row > Main connection and to the second tLogRow
    component using a Row > Reject connection.
  5. Connect the tSalesforceConnection component to the first
    tSalesforceInput component using a Trigger > On Subjob Ok connection.
  6. Do the same to connect the first tSalesforceInput
    component to the first tFixedFlowInput component, the
    first tFixedFlowInput component to the second
    tFixedFlowInput component, the second
    tFixedFlowInput component to the third
    tFixedFlowInput component, the third
    tFixedFlowInput component to the second
    tSalesforceInput component, and the second
    tSalesforceInput component to the third
    tSalesforceInput component.

Opening a connection to Salesforce

  1. Double-click the tSalesforceConnection component to open
    its Basic settings view on the
    Component tab.
  2. Select Basic from the Connection
    type
    drop-down list to connect to Salesforce using your
    Salesforce account username, password, and security token.

    In this example, you connect to Salesforce using the basic connection type.
    You can also connect to Salesforce using the OAuth JWT (JSON Web Token) Flow
    type. For more information, see the related description of how to
    connect to Salesforce using OAuth JWT Flow on Talend Help Center (https://help.talend.com)
    .

  3. In the User Id field, enter your Salesforce
    username.
  4. Click the […] button next to the
    Password field and in the pop-up dialog box, enter
    your Salesforce password between double quotation marks.
  5. Click the […] button next to the Security
    Token
    field and in the pop-up dialog box, enter your Salesforce
    security token between double quotation marks.

    You can use the Salesforce metadata wizard to create a connection to your
    Salesforce system, save the connection in the Repository, and then reuse the
    connection configuration defined in the metadata wizard in Salesforce
    components. For more information, see the related description of
    centralizing Salesforce metadata.

Deleting Salesforce Account records based on external ID

  1. Double-click the first tSalesforceInput component to
    open its Basic settings view on the
    Component tab.
  2. Select the component that will create the Salesforce connection from the
    Connection Component drop-down list,
    tSalesforceConnection_1 in this example.
  3. Click the […] button next to the Module
    Name
    field and in the pop-up dialog box, select the object whose
    data will be deleted, Account in this example. The schema
    of the Account object will be automatically filled.
  4. Click OK to save the changes and in the pop-up dialog
    box, click Yes to propagate the schema to the next
    tSalesforceOutput component.
  5. Select Query from the Query Mode
    drop-down list and specify the condition used to filter data to be deleted. In
    this example, it is talendlena__Account_External_ID__c like
    '%talend%'
    .

    All Salesforce Account records whose
    talendlena__Account_External_ID__c field contains
    talend will be deleted.

  6. Double-click the first tSalesforceOutput component to
    open its Basic settings view on the
    Component tab.
  7. Select the component that will create the Salesforce connection from the
    Connection Component drop-down list,
    tSalesforceConnection_1 in this example.
  8. Click the […] button next to the Module
    Name
    field and in the pop-up dialog box, select the object whose
    data will be deleted, Account in this example.
  9. Select DELETE from the Output
    Action
    drop-down list to perform the delete operation on the
    Account objects filtered by the first tSalesforceInput
    component.

Inserting Salesforce Account records with external IDs

  1. Double-click the second tSalesforceOutput component to
    open its Basic settings view on the
    Component tab.
  2. Select the component that will create the Salesforce connection from the
    Connection Component drop-down list,
    tSalesforceConnection_1 in this example.
  3. Click the […] button next to the Module
    Name
    field and in the pop-up dialog box, select the object into
    which data will be inserted, Account in this example. The
    schema of the Account object will be automatically filled.
  4. Click the […] button next to Edit
    schema
    and in the pop-up dialog box, remove all schema columns
    except the two columns Name and
    talendlena__Account_External_ID__c. Then click tSalesforceOutput_4.png to copy these two
    columns to the first tFixedFlowInput component. When
    done, click OK to close the dialog box.
  5. Select INSERT from the Output
    Action
    drop-down list.
  6. Double-click the first tFixedFlowInput component to open
    its Basic settings view on the
    Component tab.

    tSalesforceOutput_5.png

  7. In the Mode area, select Use Inline
    Table
    and in the table displayed, enter the data to be inserted
    into the Salesforce Accout object. In this example, the following two records
    will be inserted.

    You can also select Use Inline Content, and then copy
    and paste the input data into the Content field
    displayed.

Inserting Salesforce Contact records upon Account external IDs

  1. Double-click the third tSalesforceOutput component to
    open its Basic settings view on the
    Component tab.
  2. Select the component that will create the Salesforce connection from the
    Connection Component drop-down list,
    tSalesforceConnection_1 in this example.
  3. Click the […] button next to the Module
    Name
    field and in the pop-up dialog box, select the object into
    which data will be inserted, Contact in this example. The
    schema of the Contact object will be automatically filled. When done, click
    OK to save the changes and in the pop-up dialog box,
    click Yes to propagate the schema to the next two
    tLogRow components.
  4. Click the […] button next to Edit
    schema
    and in the pop-up dialog box, remove all schema columns
    except the three columns LastName,
    FirstName, and
    talendlena__Contact_Talend_ID__c. Then add another
    column Account_External_ID of String type and copy these
    four columns to the second tFixedFlowInput component.
    When done, click OK to close the dialog box and in the
    pop-up dialog box, click Yes to propagate the schema to
    the next two tLogRow components.

    tSalesforceOutput_6.png

  5. Select UPSERT from the Output
    Action
    drop-down list and
    talendlena__Contact_Talend_ID__c from the
    Upsert Key Column drop-down list displayed.
  6. Go to the Advanced settings view and in the
    Relationship mapping for upsert table, specify the
    relationship mapping for the column Account_External_ID
    by adding one row and setting the value for each table column. In this example,
    the column Account_External_ID is mapped with the
    external ID field talendlena__Account_External_ID__c of
    the Account object, so the value for Column name of Talend
    Schema
    is Account_External_ID, the value
    for Lookup relationship field name and Module
    name
    is Account, and the value for
    External id name is
    talendlena__Account_External_ID__c.

    tSalesforceOutput_7.png

  7. Clear the Extend Insert and Die on
    Error
    check boxes so that erroneous data can be gathered via the Row > Reject connection.
  8. Double-click the second tFixedFlowInput component to
    open its Basic settings view on the
    Component tab.

    tSalesforceOutput_8.png

  9. In the Mode area, select Use Inline
    Table
    and in the table displayed, enter the data to be inserted
    into the Salesforce Contact object. In this example, the input data is as
    follows.

    You can also select Use Inline Content, and then copy
    and paste the input data into the Content field
    displayed.

  10. Double-click the first tLogRow component and on its
    Basic settings view, select
    Table in the Mode area to
    display the result in a table.
  11. Do the same to configure the second tLogRow
    component.

Updating Salesforce Contact records upon Account external IDs

  1. Double-click the fourth tSalesforceOutput component to
    open its Basic settings view on the
    Component tab.
  2. Select the component that will create the Salesforce connection from the
    Connection Component drop-down list,
    tSalesforceConnection_1 in this example.
  3. Click the […] button next to the Module
    Name
    field and in the pop-up dialog box, select the object into
    which data will be inserted, Contact in this example. The
    schema of the Contact object will be automatically filled.
  4. Click the […] button next to Edit
    schema
    and in the pop-up dialog box, remove all schema columns
    except the three columns Phone,
    Email, and
    talendlena__Contact_Talend_ID__c. Then add another
    column Account_External_ID of String type and copy these
    four columns to the second tFixedFlowInput component.
    When done, click OK to close the dialog box.
  5. Select UPSERT from the Output
    Action
    drop-down list and
    talendlena__Contact_Talend_ID__c from the
    Upsert Key Column drop-down list displayed.
  6. Go to the Advanced settings view and in the
    Relationship mapping for upsert table, specify the
    relationship mapping for the column Account_External_ID
    by adding one row and setting the value for each table column. In this example,
    the column Account_External_ID is mapped with the
    external ID field talendlena__Account_External_ID__c of
    the Account object, so the value for Column name of Talend
    Schema
    is Account_External_ID, the value
    for Lookup relationship field name and Module
    name
    is Account, and the value for
    External id name is
    talendlena__Account_External_ID__c.
  7. Double-click the third tFixedFlowInput component to open
    its Basic settings view on the
    Component tab.

    tSalesforceOutput_9.png

  8. In the Mode area, select Use Inline
    Table
    and in the table displayed, enter the data used to update
    the two records inserted into the Salesforce Contact object. In this example,
    the updated data is as follows. The phone and email values will be added for
    both two records and the Account external ID value for the second record is
    updated to account_talend_doc_exid.

    You can also select Use Inline Content, and then copy
    and paste the input data into the Content field
    displayed.

Retrieving inserted Salesforce Account records

  1. Double-click the second tSalesforceInput component to
    open its Basic settings view on the
    Component tab.
  2. Select the component that will create the Salesforce connection from the
    Connection Component drop-down list,
    tSalesforceConnection_1 in this example.
  3. Click the […] button next to the Module
    Name
    field and in the pop-up dialog box, select the object from
    which data will be retrieved, Account in this example.
    The schema of the Account object will be automatically filled.
  4. Click the […] button next to Edit
    schema
    and in the pop-up dialog box, remove all schema columns
    except the three columns Id, Name,
    and talendlena__Account_External_ID__c. When done, click
    OK to save the changes and in the pop-up dialog box,
    click Yes to propagate the schema to the next
    tLogRow component.
  5. Select Query from the Query Mode
    drop-down list and specify the condition used to filter data to be retrieved. In
    this example, it is Name like '%talend%'.

    All Salesforce Account records whose Name field
    contains talend will be retrieved.

  6. Double-click the third tLogRow component and on its
    Basic settings view, select
    Table in the Mode area to
    display the result in a table.

Retrieving updated Salesforce Contact records using SOQL query

  1. Double-click the third tSalesforceInput component to
    open its Basic settings view on the
    Component tab.
  2. Select the component that will create the Salesforce connection from the
    Connection Component drop-down list,
    tSalesforceConnection_1 in this example.
  3. Click the […] button next to the Module
    Name
    field and in the pop-up dialog box, select the object from
    which data will be retrieved, Contact in this example.
    The schema of the Contact object will be automatically filled.
  4. Click the […] button next to Edit
    schema
    and in the pop-up dialog box, remove all schema columns
    except the four columns Name,
    Phone, Email, and
    talendlena__Contact_Talend_ID__c.

    tSalesforceOutput_10.png

  5. Add another two columns to retrieve name and external ID of the linked Account
    object, Contact_Account_Name and
    Contact_Account_talendlena__Account_External_ID__c in
    this example.

    To retrieve data of a linked object column, it is necessary to define the
    name of the column in a particular manner in the schema editor. The correct
    syntax is NameofCurrentObject_NameofLinkedObject_NameofColumnofInterest.
    If this syntax is not respected, data from the linked object will not be
    returned. For more information about how to set schema for the relationship
    query, see How to set schema for the guess query feature of tSalesforceInput.

  6. Click OK to save the changes. In the pop-up dialog box,
    click Yes to propagate the schema to the next
    tLogRow component.
  7. Select Query from the Query Mode
    drop-down list.
  8. Select the Manual Query check box and click the
    Guess query button to generate the SOQL query based
    on the defined module name and schema columns. The generated SOQL query will
    look like below.

  9. In the generated SOQL query string, replace each underscore character after the
    object name in the column name
    Contact_Account_talendlena__Account_External_ID__c
    with a dot character. Then add the WHERE condition clause used to filter data to
    be retrieved at the end of the generated SOQL query. In this example, it is
    talendlena__Contact_Talend_ID__c like '201801%' and
    all Salesforce Contact records whose
    talendlena__Contact_Talend_ID__c field begins with
    201801 will be retrieved. The updated SOQL query will
    look like below.

  10. Double-click the fourth tLogRow component and on its
    Basic settings view, select
    Table in the Mode area to
    display the result in a table.

Executing the Job to upsert Salesforce data based on external ID

  1. Press Ctrl + S to save your Job.
  2. Press F6 to execute your Job.

    tSalesforceOutput_11.png

    As shown above, two Account records account_talend and
    account_talend_doc are successfully inserted, two
    Contact records Beckham David and Taylor
    Swift
    are successfully inserted and updated based on the
    mapping relationship with the external IDs in the Account object, and
    another Contact record missing the value for the required field
    LastName is not inserted.

    You can also go to the Salesforce website to double-check the Job execution
    result.

    tSalesforceOutput_12.png
    tSalesforceOutput_13.png


Document get from Talend https://help.talend.com
Thank you for watching.
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x