How to find insert or update using Apex in Salesforce?

Sample Code:

Visualforce Page:

<apex:page standardController="Account" extensions="Sample">
<apex:form >
    <apex:pageMessage rendered="{!NOT(updateBool)}" severity="info">Insert</apex:pageMessage>
    <apex:pageMessage rendered="{!updateBool}" severity="info">Update</apex:pageMessage>


Apex Class:

public class Sample {
    public Boolean updateBool {get;set;}

    public Sample(ApexPages.StandardController controller) {
        Account a = (Account)controller.getRecord();
        updateBool = a.Id == null ? false : true;


No comments:

Post a Comment

Sharing is Caring!!! Share this with your friends!!!

submit to reddit