This article will explain how you can create a master-detail, or lookup, relationship in which offline creation is supported.
An offline master-detail or lookup relationship utilises both a proxy ID and a proxy lookup, to give the record a temporary ID until it syncs with the platform. After the sync has been completed and the record has been assigned a real ID the proxy ensures that the relationship can still be understood by the platform and is not lost on upload.
These relationships allow a record or set of records to be attached to a parent, allowing for example, a list of employees to be related to the store they are working in. The proxy field must exist parallel to each master-detail field as a placeholder for the ID that will populate the lookup value after the record has been synced.
It is more than likely that you will create both a parent and a child record while offline, however until synced with the platform these cannot have real ID values. MobileCaddy uses extra fields and metadata to manage these references after they have been uploaded, ensuring the platform understands which child relates to which parent.
Using the example of a Sale__c object, that has children Sale_Items__c objects as follows, we will cover the steps needed to manage this offline relationship.
- Assuming you already have a master-detail/lookup field in the Sale_Items__c object called Sale__c, create a textarea 255 field called MC_PLU_Sale__c on the Sale_Items__c object, and mobilise it with CRUD settings CY_RY_UY_DN.
- Against the Sale__c field in Sale_Items__c add the Proxy Reference Field Name to MC_PLU_Sale__c – This is done using this button inside the record for the Sale__c field in the Sale_Items__c table version.
- Select the MC_PLU_Sale__c or respective button inside of this screen. After selecting it you will then be able to create offline records using your master-detail.
As changing these settings alters your application metadata, you must ensure your developer scrubs the metadata and updates the application.