function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Amita TatarAmita Tatar 

pop up alert messages

Hi guys, please help me how we can show pop up messages after performing DML operations insert,update,etc in salesforce
Sumit Kumar Singh 9Sumit Kumar Singh 9
You can try this -
<apex:page controller="insertRec">
<script>
    function insertAccount() {
        Visualforce.remoting.Manager.invokeAction(                     
        '{!$RemoteAction.insertRec.InsertConRec}',                
            function(result, event) {
                alert(result);
            }, 
            { buffer: true, escape: true, timeout: 120000 }                   
        );
    }
</script>
    <apex:form>
        <a href="" onclick="insertAccount();" styleclass="btn"> Insert Contact </a>
    </apex:form>
</apex:page>
public class insertRec {
    @RemoteAction
    public static string InsertConRec() {
        string messageString = '';
        try {
            contact c = new Contact();
            c.lastName = 'Test';
            insert c;
            messageString = 'Successfully inserted the record.'; 
        } catch (Exception e) {
            messageString = e.getMessage();    
        }
        return messageString ; 
    }
}


 
Rogerio Lara 2028Rogerio Lara 2028
Hi Sumit,

I saw your post and I think this could be the potential solution to what I am trying to achieve. 

I'm getting an Error: Compile Error: unexpected token: '<' at line 1 column 0

Any ideas why this is happening?

Thank you,