Get A GE Object
When you need to manipulate a record, you'll want to use the Aptify JavaScript API's version of a Generic Entity Object.
Step-by-step guide
Know the Entity Name and Record ID of the record you're interested in.
Creating a New Reocrd
Just as in the Aptify .NET API, creating a GE Object with a Record ID of -1 and saving it will create a new record in the database.
Call the Aptify.framework.genericEntity.getEntityObject() function, which passes an object containing the GE Object into its callback function.
One way to call getEntityObject() is to pass each piece of data as a separate parameter:
Obtaining a GE Object for Persons record with ID 10Aptify.framework.genericEntity.getEntityObject("Persons", 10, function (result) { if (result.success) { var personGE = result.GE; // You can now use personGE } });
Alternately, you can pass each piece of data as a property of a single object parameter:
Obtaining a GE Object for Persons record with ID 10Aptify.framework.genericEntity.getEntityObject({ entity: "Persons", recordId: 10, callBack: function (result) { if (result.success) { var personGE = result.GE; // You can now use personGE } } });
Beware making synchronous assumptions!
Even though Aptify.framework.genericEntity.getEntityObject() is capable of synchronously returning a GE Object, you should never assume that it will do so. The best practice is to use the GE Object provided in the callback function, as shown above.
// The wrong way to do it: var personGE = Aptify.framework.genericEntity.getEntityObject("Persons", 10); // personGE may or may not be undefined at this point, //depending on whether getEntityObject() executed synchronously
Related articles
Copyright © 2014-2017 Aptify - Confidential and Proprietary