...
Note |
---|
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.
Code Block language js linenumbers true // 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, and get the subtype records. This gives you access to the subtype, which has helpful methods to find the subtype record you are looking for.
Code Block language js linenumbers true var personGESubTypes = personGE.subTypes; var personCompanySubType = personGESubTypes.findByName(subTypeName); var personCompanyRecords
If you know the subtype record's ID, you can use the findRecordById() function:
Code Block language js linenumbers true 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:
Code Block language js linenumbers true 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:
Code Block language js linenumbers true 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 (Content by label) | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|