Salesforce

Sugar - Referencing Objects by IDs (Magic xpi 4.5)

« Go Back

Information

 
Created ByKnowledge Migration User
Approval Process StatusPublished
Objective
Description

Sugar - Referencing Objects by IDs (Magic xpi 4.5)

Referencing Objects by Object IDs

When you query, create, or delete a Sugar 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 (ModuleName, FieldName, FieldValue, ErrorIfEmpty)' in which:

  • ModuleName is the name of the Sugar module exactly as it appears in the API.

  • FieldName is the name of the module field that is used in the query’s WHERE field.

  • FieldValue is the value to query.

  • ErrorIfEmpty, when set to true, determines that:

    • If the method does not find an ID, the operation will not be performed.

    • If the getObjectIDbyField function returns an empty value, then:

      • The Create operation will not create an object, and an error will be returned in the result XML.

      • The Update operation will not update an object, and an error will be returned in the result XML.

      • The Query operation will fail, and an error will be returned in the result XML.

For example: 'getObjectIDbyField (Accounts, name, ABC, true)' 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.

Note:

When you use the getObjectIDbyField function, only the first ID that was found is returned if the search discovers more than one entry.

Reference
Attachment 
Attachment