Salesforce

Salesforce - Referencing Objects by IDs (Magic xpi 4.7)

« Go Back

Information

 
Created ByKnowledge Migration User
Approval Process StatusPublished
Objective
Description

Salesforce - Referencing Objects by IDs (Magic xpi 4.7)

Referencing Objects By Object IDs

When you query, create, or delete a Salesforce object, which is dependent on a parent object, you need to retrieve the parent object's ID.

To simplify this process, you can use the getObjectIDbyField function in the node's Calculated Value field in the Properties pane.

The syntax of the function is: 'getObjectIDbyField (ObjectName, FieldName, FieldValue)' in which:

  • ObjectName is the name of the object exactly as it appears in the WSDL.

  • FieldName is the name of an entry in the WSDL of the object.

  • FieldValue is the value to query.

For example: 'getObjectIDbyField (Account, Name, ABC)' returns the ID of the account whose name is ABC.

It is important to make sure that the whole expression is enclosed by single straight quotation marks, as shown above.

When you use the getObjectIDbyField function, you should be aware of the following points:

  • You can only search for one parameter in a specific function.

  • If the search discovers more than one entry, only the first ID that was found is returned.

  • If it returns an error, no operation is performed on this record and execution skips to the next record. (Errors are returned in the result XML and not as errors visible in the Magic xpi Monitor.)

  • This function can be used only on fields defined as referencing an object. For example, referencing a user as the owner of the opportunity when creating a new opportunity.

  • When this function is used on a field that does not reference an object, Salesforce returns an error.

  • Each call to this function sends a request to Salesforce.

Referencing Objects By External IDs

You can reference an object according to an external ID, instead of its object ID. This is useful when, for example, an object is generated in another database, such as SAP, and its object ID is unknown to you.

To do this, use the setRefbyExternalId function in the node's Calculated Value field in the Properties pane. The mapped node must be a lookup field (as per the Salesforce user interface).

The syntax of the function is: 'setRefbyExternalId (ObjectName, ExternalIdFieldName, ExternalIdFieldValue)', in which:

  • ObjectName is the name of the object exactly as it appears in the WSDL.

  • ExternalIdFieldName is the name of an entry in the WSDL of the object.

  • ExternalIdFieldValue is the value to query.

For a more detailed example of how to use the setRefbyExternalId function, click here.

  • This function can only be used on Create, Update, and Upsert operations, and on fields that are marked as external IDs.

  • This function cannot be used on Bulk Create, Bulk Update and Bulk Upsert operations.

Reference
Attachment 
Attachment