rbv_api.getRelatedIds2()

Purpose

For external objects (such as those mapped to external tables, to OpenEdge Service objects, or through a HDP connection), returns an array of related IDs for a specified relationship and record ID.

Note: For native Platform objects, you can use the method, rbv_api.getRelatedIds().

Syntax

rbv_api.getRelatedIds2(relName, objName, Id)

Parameters

relName

Integration name of the relationship.

Throws an exception if the specified relationship integration name does not exist.

ObjName

Integration name of the object.

Throws an exception if the specified object integration name does not exist.

Id

Record ID from one side of the relationship.

Throws an exception if the supplied ID does not resolve to a record in the specified object, or if the value is negative, zero, or otherwise invalid.

Return value

Returns an array of IDs for records related through the specified relationship.

  • If related records exist, the array contains one or more record IDs.

  • If no related records exist, the method may return an empty array.

Example

Retrieve the IDs of records related through a specified relationship.

var arr = rbv_api.getRelatedIds2("R1321", "ex_group", "{!#UID}");
rbv_api.printArr(arr);

Example: Handling Empty Results

The following example checks whether any related records were returned.

var arr = rbv_api.getRelatedIds2("R1321", "ex_group", "{!#UID}");
if (arr.length === 0) {
rbv_api.println("No related records found.");
}
else {
rbv_api.printArr(arr);
}

Example: Handling Exceptions

The following example demonstrates how to handle errors that may occur when the relationship name, object name, or record ID is invalid.

try {
var arr = rbv_api.getRelatedIds2("R1321", "ex_group", "{!#UID}");
if (arr.length === 0) {
rbv_api.println("No related records found.");
}
}
catch (e) {
rbv_api.println("Unable to retrieve related records: " + e);
}