rbv_api.attachAsync()

Purpose

This Object Script method schedules a background job to create relationship with multiple records. Optionally, it uses a valid input script snippet - runExpression, and evaluates it once the scheduled job is executed.

Formulas used in the runExpression snippet and Object Script triggers can include other API methods and regular Platform template functionality, such as loops. Object Script methods are not affected if called outside the update triggers.

Parameters

relName, objName1, objId1, objName2, objIds2, runExpression

Syntax

rbv_api.attachAsync (relName, objName1, objId1, objName2, objIds2, runExpression)

relName

Integration name of the relationship.

objName1

Integration name of the first object.

objId1

ID of the first object record.

objName2

Integration name of the second object.

objIds2

Array of numeric IDs of the second object record.

runExpression

(Optional) A string containing formula that can include other API methods.

Permissions required

Edit permission for the selected object types.

Return value

None. The method schedules a background job.

Example

In the input, ensure the array ids constitutes only the number type valid record IDs.

var selResult = rbv_api.selectQuery2("SELECT ID, PRICE FROM LineItem where PRICE>0", 0, 10, null, null);
var ids = [];
for(var i=0; i<selResult.length; i++)
{
ids[i] = Number(selResult[i][0]);
}
var codeSnippet = 'rbv_api.runTrigger("Invoice", {!id}, "GenerateInvoice", false, false)';
rbv_api.attachAsync("R36189", "Invoice", {!id}, "LineItem", ids, codeSnippet);