• Mayank Deshpande 22
  • NEWBIE
  • 20 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 2
    Replies
I have requirement that when i click on save button on account object three record created  in Account object  having self relationship in three records.

means ---- when user click save {A,B,C} account created and A' ID is realted with B and C record , B's ID related with A.C record and same with C 

kindly suggest how we can achive this in best possible way
i write code to search a contact ----- wnat to debug this code in developer consol , but not able to do the same 
Public Class ContactSearch{
List <Contact> Con = New List<Contact>();
Public List<Contact> searchForContacts (String A, String B){
Con = [ Select Id , FirstName,LastName from Contact where lastname='A' and MailingPostalCode='B'];
return (Con);}
}
in developer consol i write one apex class and called a method of contact search class but getting error Line: 1, Column: 1
Unexpected token 'Public'.

Public Class NewContactSerach {
    
    ContactSearch Contc = New ContactSearch ();
    Contc.searchForContacts(Deshpande.abcde);
}

plz suggest me how to overcome from this 
Apex code 

public with sharing class getopportunity {
public ApexPages.StandardSetController opty {
get {
 if (opty==null)
 {
 ApexPages.StandardSetController opty = New ApexPages.StandardSetController (Database.getquerylocator([select Name, CloseDate FROM Opportunity])); } 
 return opty;} 
 set;} 
 public List<Opportunity> getOpportunities() { 
 return (List<Opportunity>) opty.getRecords();} 
 }
Apex Code =  ublic with sharing class Saveaccountdetail {
Public Account Account {get;set;}
Public Account Accts {get;set;}
Public Saveaccountdetail (){
Id id= ApexPages.currentPage().getParameters().get('id');
Accts = (id == null)? new Account() : [SELECT Name, Phone, Industry FROM Account WHERE Id = :id];
}
Public PageReference Save()
{try  
{
insert (Accts);
}
catch(System.DMLException e) {
ApexPages.addMessages(e);
return null;
}
PageReference redirectSuccess = new ApexPages.StandardController(Account).view();
return (redirectSuccess);
}
}

Visual Force Page 
<apex:page controller="Saveaccountdetail" tabStyle="Account" > <apex:form > <apex:pageBlock title="New Account"> <apex:pageBlockSection > <apex:inputField value="{!Account.name}" /> <apex:inputField value="{!Account.Industry}" /> <apex:inputField value="{!Account.Phone}" /> </apex:pageBlockSection> <apex:commandButton value="Save" action="{!Save}"/> </apex:pageBlock> </apex:form> </apex:page>
i write code to search a contact ----- wnat to debug this code in developer consol , but not able to do the same 
Public Class ContactSearch{
List <Contact> Con = New List<Contact>();
Public List<Contact> searchForContacts (String A, String B){
Con = [ Select Id , FirstName,LastName from Contact where lastname='A' and MailingPostalCode='B'];
return (Con);}
}
in developer consol i write one apex class and called a method of contact search class but getting error Line: 1, Column: 1
Unexpected token 'Public'.

Public Class NewContactSerach {
    
    ContactSearch Contc = New ContactSearch ();
    Contc.searchForContacts(Deshpande.abcde);
}

plz suggest me how to overcome from this 
Apex Code =  ublic with sharing class Saveaccountdetail {
Public Account Account {get;set;}
Public Account Accts {get;set;}
Public Saveaccountdetail (){
Id id= ApexPages.currentPage().getParameters().get('id');
Accts = (id == null)? new Account() : [SELECT Name, Phone, Industry FROM Account WHERE Id = :id];
}
Public PageReference Save()
{try  
{
insert (Accts);
}
catch(System.DMLException e) {
ApexPages.addMessages(e);
return null;
}
PageReference redirectSuccess = new ApexPages.StandardController(Account).view();
return (redirectSuccess);
}
}

Visual Force Page 
<apex:page controller="Saveaccountdetail" tabStyle="Account" > <apex:form > <apex:pageBlock title="New Account"> <apex:pageBlockSection > <apex:inputField value="{!Account.name}" /> <apex:inputField value="{!Account.Industry}" /> <apex:inputField value="{!Account.Phone}" /> </apex:pageBlockSection> <apex:commandButton value="Save" action="{!Save}"/> </apex:pageBlock> </apex:form> </apex:page>