• sharath kanukuntla 7
  • NEWBIE
  • 10 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 3
    Replies
When i clone for first time parent opp name is coming in my custom field..

 https://ap2.salesforce.com/{!Opportunity.Id}/e? clone=1&retURL=%2F{!Opportunity.Id}&00N2800000Fhvcq={!Opportunity.Name}

but again iam trying to cloning am getting the cloned record name but not main parent name..
Error: Enter a URL that is valid and well-formed
!IF( Opportunity.Parent_Opportunity__c ='',

 https://ap2.salesforce.com/{!Opportunity.Id}/e? clone=1&retURL=%2F{!Opportunity.Id}&00N2800000Fhvcq={!Opportunity.Name},

 Opportunity.Parent_Opportunity__c)}

thanks in advance.
error:Error: AccountWithAssociatedContact_class Compile Error: Initial expression is of incorrect type, expected: System.SelectOption at line 62 column 57
vf============
<apex:page controller="AccountWithAssociatedContact_class">
 <apex:form >
  <apex:pageBlock title="Account with related Contacts">
   <apex:pageBlockButtons >
    <apex:commandButton value="show relted contacts" action="{!displaycontacts}"/>
   </apex:pageBlockButtons>
   <apex:pageBlockSection >
    <apex:selectList size="1" label="Accounts">
     <apex:selectOptions value="{!Accounts}"/> 
       </apex:selectList><br/>
       
      <apex:selectList size="1" label="related Contacts">
       <apex:selectOptions value="{!contacts}"/>
      </apex:selectList>
   </apex:pageBlockSection>
  </apex:pageBlock>
 </apex:form>
</apex:page>

controller=====
public with sharing class AccountWithAssociatedContact_class {
    public string  acc1{set;get;}
    public string con1{set;get;}
    public list<SelectOption> contacts { get; set; }
    public list<SelectOption> Accounts { get; set; }
    //crete a wrapperclass i.e
    public list<WrapperAccountContact> Wrapper{set;get;}
    //create Map to store id(Account) and values(contacts)
    public Map<list<Account>,list<Account>> maps{set;get;}
    public class WrapperAccountContact{
    public list<Account> Acc{set;get;}
    public list<Account> con{set;get;}
   
    }
    
    public AccountWithAssociatedContact_class(){
    Accounts =new list<SelectOption>();
    contacts=new list<SelectOption>();
    Wrapper = new list<WrapperAccountContact>();
    maps=new Map<list<Account>,list<Account>>();
    list<Account> acc1=[SELECT id,name FROM Account];
      WrapperAccountContact w1= new WrapperAccountContact();
      w1.Acc=Acc1;
      Wrapper.add(w1);
            //string query1='SELECT id,name FROM Account';
            //acc1=database.query(query1);
    
    
    list<Account> con1=[SELECT id,name,(SELECT id,name FROM Contacts) FROm Account];
    WrapperAccountContact w2= new WrapperAccountContact();
    w2.con=con1;   
    wrapper.add(w2);
          //string query2='SELECT id,name,(SELECT id,name FROM Contacts) FROm Account';
         //con1=database.query(query2);
    
    /*for(Account a:acc1){
     WrapperAccountContact w1= new WrapperAccountContact();
      w1.Acc=Acc1;
      Wrapper.add(w1);
    }*/
    
   /*for(Account a:acc1){
    WrapperAccountContact w2= new WrapperAccountContact();
    w2.con=con1;   
    wrapper.add(w2);
    }*/
    
     selectoption op = new selectOption('--None--','--None--');
       Accounts.add(op);
       contacts.add(op);
       
      
    for(WrapperAccountContact w:wrapper){
         maps.put(w.acc,w.con);
        system.debug('value in map are========='+maps);
    }
      Set<List<Account>> keys=maps.keySet();
       system.debug('id in keysare========='+keys);
       
       
                        for(List<Account> s:keys){
        62--line>    list<selectOption> lst = new list<selectOption>{s,s};
          
        }       
    }
    
   
    
    public PageReference displaycontacts() {
        return null;
    }
    
    

  
}
in my code iam getting itemlebels in picklist instead of Accont..but it is showing(size) number of Accounts
vf========
<apex:page controller="AccountWithAssociatedContacts_class">
  <apex:form >
  <b>No of Accounts</b>{!k}
   <apex:pageBlock >
    <apex:pageBlockSection >
     <apex:selectList size="1" multiselect="fasle" value="{!listofAccounts}">
      <apex:selectOptions value="{!options}"/>
     </apex:selectList>
    </apex:pageBlockSection>
   </apex:pageBlock>
   <apex:pageBlock >
   <apex:pageBlockButtons location="top">
    <apex:commandButton value="displayContacts" action="{!displayContacts}"/>
   </apex:pageBlockButtons>
    <apex:pageBlockTable value="{!cons}" var="c">
     <apex:column headerValue="Name" value="{!c.Name}"/>
     <apex:column headerValue="Email" value="{!c.email}"/>
     <apex:column headerValue="phone" value="{!c.phone}"/>
    </apex:pageBlockTable>
   </apex:pageBlock>
  </apex:form>
</apex:page>

class=-==============
public class AccountWithAssociatedContacts_class {

    public PageReference displayContacts() {
    cons=[SELECT id,name,email,phone FROM Contact WHERE Accountid=:listofAccounts];
        return null;
    }

    public String listofAccounts { get; set; }
    public integer k{set;get;}
    public list<Account> Display{set;get;}
    public list<contact> cons { set; get; }
    public list<SelectOption> options{ set; get; }
    
    public AccountWithAssociatedContacts_class(){
    options=new list<SelectOption>();
    options.add(new selectOption('','---------------None---------------'));
    display=[SELECT id,name,phone FROM Account];
    system.debug('Accounts are===='+display);
    if(!display.isEmpty()){     
    for(Account a1:display){
    options.add(new selectOption('a1.id','a1.name'));    
    k=display.size();    
    }
    
   }
  }
}

thanks in advance
 
When i clone for first time parent opp name is coming in my custom field..

 https://ap2.salesforce.com/{!Opportunity.Id}/e? clone=1&retURL=%2F{!Opportunity.Id}&00N2800000Fhvcq={!Opportunity.Name}

but again iam trying to cloning am getting the cloned record name but not main parent name..
Error: Enter a URL that is valid and well-formed
!IF( Opportunity.Parent_Opportunity__c ='',

 https://ap2.salesforce.com/{!Opportunity.Id}/e? clone=1&retURL=%2F{!Opportunity.Id}&00N2800000Fhvcq={!Opportunity.Name},

 Opportunity.Parent_Opportunity__c)}

thanks in advance.