You need to sign in to do that
Don't have an account?
fujih
Conditionally edit or create custom object record
I want to add functionality in a custom button to convert a pending agreement into an agreement.
Both Pending Agreement and Agreement objects are custom objects.
So when viewing a Pending Agreement and the convert to agreement button is clicked, then a check will be performed to see if an agreement already exists, if it does then edit the record otherwise create a new record.
How would I go about creating this functionality?
Where is the button is it on vf page.
At the moment I haven't created the button yet but I was thinking of just a custom button on the page layout.
If it needs to be on a vf page then so be it.
Could you please provide some pointers as to what the possible options are.
If it is on the page layout you can write java script to the button.
If it is on vf page then you can add your conditional code on the controller.
Thanks but I was looking for help with what format the code would take rather than how to implement the button.
I believe that I should be investigating triggers but how do I conditionally decide to edit an existing record or create a new record from a trigger?
Hi.
Here there is an example of how to achieve this invoking a VF from a custom button. Notice that the VF just calls its controller to perform the logic (action="{!autoRun}"). You can also add some code to the VF to catch alert messages. The controller called should then do the checks you want and probably navigate the user to the agreement detail page (PageReference pageRef = newPageReference('/'+ theId);), whether it is a newly created record or an existing one being updated.