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
AmansAmans 

DML 'Merge' statement

Hey  guys ,
I m going through the DML statements  in Apex code  , while using merge call in my class i got stuck
Im executing through my S-control in this manner
S-Control
var name = "Aman";
 var name1="Acme";
var merge_demo = sforce.apex.execute("DML","Mer_demo",{arg:name},{arg1:name1});

Class
webService static Account[] Mer_demo(String arg,String arg1)
       {
            String[] ss = new String[]{arg};
            String[] yy = new String[]{arg1};
            Account[] masterAcc = [select id,name from account where name in :ss ];
            Account[] mergeAcc = [select id,name from account where name in : yy ];
         
           try{
                merge masterAcc mergeAcc ;
            }
            catch(System.DmlException e)
            {
                alert(e);
                // process exception
            }
           
            return masterAcc;
       }

when i  execute this i got error and it didn't execute ,
anyone can help me in this

plz suggest
thx
Aman Sehgal
TechiesTechies

through merge statement you can process max 3 records including the master record.. but in your code mergeAcc may contains more than 2 records.. so first limit that and process it. And one more condition also you have to check i.e. master records should not be included in your child list....

 

 

Regards,

 

Kiran