If you have a comment on this topic, contact Aptify Documentation. If you want to return to the Aptify Community Site, please click here.

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