We are working towards making our application “Lightning Ready”. We have one functionality that we are not able to implement in lightning. I will describe it below. Please advise how we can get similar functionality in lightning.
We have two custom objects, say PARENT and CHILD. CHILD has a lookup to PARENT. We have a visualforce page where when the user clicks on a button in the context of PARENT, we create a new CHILD record, set some of the attributes and open it in edit mode. When opening in edit mode, we also set our own cancelURL page parameter. The idea is that if the user click “Cancel”, we have a mechanism to delete the newly created CHILD record. In lightning, we tried the following options.
- We can create a new CHILD record using sforce.one.createRecord. The problem here is that we cannot prepopulate any fields (other than recordtype) of the newly created CHILD record.
- We can create a new CHILD record using sforce.one.createRecord, populate the required fields, open it in edit mode using sforce.one.editRecord. The problem here is that we do not have a mechanism to delete the newly created CHILD record if the user clicks “Cancel”
- We can create a new object specific action on PARENT object. This allows us to prepopulate most of the fields before creating the CHILD record. The problem here is that this action cannot be called from visualforce/javascript.
The only viable (and not preferred) option is
- Create a custom VF page. This page will take the record type as parameter and render the fields based on a fieldset specific to the record type. The problem here is that we will deviate from defined page layout and also have to maintain separate fieldsets.