When you have a GE Object and want the GE Object for one of its subtype records, you can get it if you know the name of the subtype.
This How-To assumes you have already gone through the steps in Get A GE Object and are coding inside of a callback to Aptify.framework.genericEntity.getEntityObject(). It continues that example, assuming you have already defined personGE.
Step-by-step guide for getting a single subtype GE Object
Know the Name of the subtype Entity.
// In this example, we'll get information about a Company related to our person, so we want the PersonCompanies subtype. var subTypeName = "PersonCompanies";
Access the subtypes of your GE and find the one you want by name. This gives you access to the subtype, which has helpful methods to find the subtype record you are looking for.
var personGESubTypes = personGE.subTypes; var personCompanySubType = personGESubTypes.findByName(subTypeName);
If you know the subtype record's ID, you can use the findRecordById() function:
var aPersonCompany = personCompanySubType.findRecordById(23); // The personGE from the Get A GE Object example does not actually have PersonCompany records, so aPersonCompany will be undefined
If you want to search by some other field, you can use find(), which takes a field name and a field value:
var aPersonCompany = personCompanySubType.find("Title", "CEO"); // The personGE from the Get A GE Object example does not actually have PersonCompany records, so aPersonCompany will be undefined
Step-by-step guide for getting all subtype record GEs
If you want to loop through subtype records, you have access to an array of the subtype GEs from a property with the name of the subtype Entity:
var personCompanyGEs = personGE.PersonCompanies; console.log("There are " + personCompanyGEs.length + " PersonCompanies records on this Person."); for (var index = 0; index < personCompanyGEs.length; index++) { console.log("Title is " + personCompanyGE[index].Title + " at " + personCompanyGE[index].CompanyID_Name); }
Related articles
Filter by label
There are no items with the selected labels at this time.