Using Temporary Fields
If you need to add information to the GE Object, you can create a temporary field on the object. Â This temporary field is added to the fields collection. Â Like regular fields, temporary fields have an old value and a new value. Â When the new value and old value are different, the field is considered "dirty". Â One or more dirty fields in a GE object will mark the record as "dirty". Â This is true for temporary fields as well as regular fields. Â A dirty record will cause the form in Aptify Web to prompt the user to save the changes to the record when the form is closed. Â Dirty fields are sent to the server. Â That means temporary fields can also be used to control behavior in the server-side GE. Â This article will explain how to work with temporary fields in the Generic Entity.
Create a Temporary Field and set its Value
Use the set method on the GE to create the temporary field and set its value. Â The set method accepts two parameters: Â field and value. Â field is the name of the field and is a string. Â value is an object representing the value of the field. Â If the field doesn't exist in the fields collection of the GE, it will be created and added to the collection as a temporary field. Â Once the field has been located or created, it's value will be set wit the value property. Â Using the set method, the field will be considered dirty and the value will be sent to the server. Â If you want to set a temporary field value so that it is not dirty, refer to Set a Temporary Field Value Without Making the Field Dirty.
Set a Temporary Field Value Without Making the Field Dirty
You use the set method to create and set the value of a temporary field. Â If you do not want the field to be marked as dirty, the old value and the new value of the field must be the same. Â The GE provides a method for setting the old value of a field, setOldValue. Â Like set, setOldValue accepts two parameters: Â field and value, where field is the name of the field and value contains the value that will be used to set the field's oldValue. Â By calling setOldValue with the same value that was passed to the set method, the temporary field will exist but the GE will not consider it dirty. Â This is useful if you need to store a temporary value with the record but you do not want that value sent to the server and you do not want the GE itself to be considered dirty if the temporary field is the only value changed.
For a server-side GE (.NET), the SetAddValue method is used to create a temporary field and set its value. Â If SetAddValue is called on a field that already exists, its value will be updated.
Special Behaviors Based on the Name of the Temporary Field
_x Prefix
Temporary fields with a Name that begin with _x will not be included in the Record Change String generated by Aptify. Â This is the string that is generated based on all the dirty fields and sub-type records in a GE. Â Temporary fields that are dirty that do not begin with _x will be included in the Record Change String.
Temporary fields in the server-side GE that begin with _x are not included in the record data returned by the GetRecord endpoint.Â
_xP Prefix
On the server-side GE (.NET), temporary fields with a Name that begins with _xP will persist across a GE Rollback. Â Aptify uses this for internal processing where state must be maintained, even after a rollback.
Copyright © 2014-2017 Aptify - Confidential and Proprietary