rbv_api.getRelatedIds()
Purpose
For native Platform objects, this method returns an array of related IDs for a specified relationship and object record ID.
Syntax
rbv_api.getRelatedIds (relName, id)
Parameters
relName
Integration name of relationship
This method throws an exception if the specified relationship integration name does not exist.
id
Record ID from one side of the relationship
This method throws an exception if the supplied id does not resolve to a valid record, 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.
-
Sometimes, due to an invalid parameter value (such as 0). This method might throw an exception, for example, Data object with id 0 not found - Applications should verify input validity and handle exceptions properly when managing relationship data.
Example
Retrieve the IDs of records related through a specified relationship.
var relatedIds = rbv_api.getRelatedIds("R1234", recordId);for (var i = 0; i < relatedIds.length; i++) {rbv_api.println(relatedIds[i]);
}
Example: Handling Empty Results
The following example checks whether any related records were returned.
var relatedIds = rbv_api.getRelatedIds("R1234", recordId);if (relatedIds.length === 0) {rbv_api.println("No related records found.");}
else {for (var i = 0; i < relatedIds.length; i++) {rbv_api.println(relatedIds[i]);
}
}
Example: Handling Exceptions
The following example demonstrates how to handle errors that may occur when relationship data resolves to an invalid record identifier.
try {var relatedIds = rbv_api.getRelatedIds("R1234", recordId);if (relatedIds.length === 0) {rbv_api.println("No related records found.");}
}
catch (e) {rbv_api.println("Unable to retrieve related records: " + e);}