The user will create the record from the Quick Create and on change of specific field, the record should automatically save. Whenever the record will be saved it should open the created record.
In our scenario, we are going to use the Account Entity. When the user will enter the main phone data in the Account Quick Create Form, the record will automatically save and it will open the created account record.
- Go to Default Solution or your customization solution and Open the Quick Create Form from Account Entity
2. Click on the Form Properties to edit the form properties of Account Quick Create Form and add the script on the form.
3. Click on the +New button to add the JavasScript web resources on the form so that you can use the script function on Form Events
4. If you wanted to use an existing Web Resource then you add it or else create new by click on new
5. Create a new Script and add it on form
6. Now, we need to add the event list and bind the calling function to it. To do it click on the + New on Event Listener of Form Properties.
Note: Please don’t forget to pass the execution context as the first parameter to the function.
7. We will use formContext.data.save() function to get the created record’s GUID and open entity record using that GUID. Following is code for your reference:
8. Code Explanation:
a. quickCreateonSave is a function that is trigger on change of Main phone fields of Account Quick Create.
b. When the function is triggered we are using formcontext.data.save to save the save so that we can get the GUID of the recently created record.
c. On formcontext.data.save() we can assign two functions — on success and failure as parameter to .then() [Reference]
d. On Success, the function will return the following response where you can get the entityType, entity id, and name of the record.
e. After getting the entity id and entity type, we can use the open form to open the record as mentioned in the Code.
9. Publish all the customization that you have done on the Account Entity
I hope it helps you guys!!