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
Hrishikesh KolheHrishikesh Kolhe 

How to pass ID for Custom Objects below 3 are custom Objects, Also can anyone help me to know how to pass IDs for Custom Objects all time

public class accconopp {

public  Account_Management__c acc{get;set;}
public Contact_Management__c con{get;set;}
public Opportunity_Management__c opp{get;set;}

 public accconopp()
 {
acc=new Account_Management__c();
con=new Contact_Management__c();
opp=new Opportunity_Management__c();
}
/*
public pagereference Save()
{
insert acc;
con.AccountID=acc.id;
insert con;
opp.AccountID=acc.id;
insert opp;
pagereference pr=new
pagereference('/'+acc.id);
 return pr;
}
*/
public pagereference cancel(){
pagereference can= new pagereference('/'+acc.id);
return can;
}

}
How to face errrors while working on custom Objects and IDs
Maharajan CMaharajan C
Hi  Kolhe,

Please use you Account Id api name properly from the related custom object:

Setup => Object Manager => Contact Management =>  Fields & Relationship => Copy the Account Field Name.(Don't use the label)
 
public pagereference Save()
{
insert acc;
con.Account__c = acc.id;
insert con;
opp.Account__c = acc.id;
insert opp;
pagereference pr=new
pagereference('/'+acc.id);
 return pr;
}

Thanks,
Maharajan.C