• Avinash Dhanke 32
  • NEWBIE
  • 10 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 5
    Replies
I built visualforce page but i have one get a error on that when we click on radiobutton and select one value in deopdown and click on clone button following screenshot is belowUser-added image
i Have created the handler for that in the text filed  i want the name but populated the id  following is my code

public class Populatedlookup {


    Public void updateField(List<Lead> leadList){
        /*
        for(lead l : leadList){
            leadId.add(l.Id);
            System.debug('leadid'+ leadId.add(l.Id));
        }
        lead leadOne = [select id, name, Channel_Partner__c from lead where Id IN: leadId];
        if(leadOne.Channel_Partner__c!=null){
        Distributor__c dis = [select id, name from Distributor__c where Id=:leadOne.Channel_Partner__c];
        DistributorName = dis.Name;
*/
        for(Lead leadObj:LeadList){
            if(leadObj.Channel_Partner__c!=null){
                leadObj.Channel_Partner_Text__c=leadObj.Channel_Partner__r.Name;
            }
            else{
                leadObj.Channel_Partner_Text__c='';
            }
            
        }
      
    }
}
trigger updateAccountIfOppCustomer on Opportunity (after insert,after update) {
    List<Account>accToupdate=new List<Account>();
    List<Opportunity>opps = new List<Opportunity>();
    set<id>associatedAccid = new set<id>();
    for(Opportunity opp :trigger.new){
        associatedAccid.add(opp.AccountId);
        System.debug('associatedAccid'+opp.AccountId);
    }
    //Map<id,Account>Accmap=new Map<id,Account>
    opps =[Select id,Accountid,StageName,Account.Type From Opportunity Where Accountid =:associatedAccid];
    System.debug('Opportunity' +opps);
    for(Opportunity opp:opps){
        if(opp.StageName=='Closed Won-One Time'||opp.StageName=='Closed Won-Recurring'||opp.StageName=='Customer Reseller'){
            opp.Account.Type='Customer-Direct';
            accToupdate.add(opp.Account);
            System.debug('accToupdate'+opp.Account);
        }
        else{
            opp.Account.Type='Prospect';
           accToupdate.add(opp.Account);
        }
    }
    update accToupdate;
}
i Have created the handler for that in the text filed  i want the name but populated the id  following is my code

public class Populatedlookup {


    Public void updateField(List<Lead> leadList){
        /*
        for(lead l : leadList){
            leadId.add(l.Id);
            System.debug('leadid'+ leadId.add(l.Id));
        }
        lead leadOne = [select id, name, Channel_Partner__c from lead where Id IN: leadId];
        if(leadOne.Channel_Partner__c!=null){
        Distributor__c dis = [select id, name from Distributor__c where Id=:leadOne.Channel_Partner__c];
        DistributorName = dis.Name;
*/
        for(Lead leadObj:LeadList){
            if(leadObj.Channel_Partner__c!=null){
                leadObj.Channel_Partner_Text__c=leadObj.Channel_Partner__r.Name;
            }
            else{
                leadObj.Channel_Partner_Text__c='';
            }
            
        }
      
    }
}
trigger updateAccountIfOppCustomer on Opportunity (after insert,after update) {
    List<Account>accToupdate=new List<Account>();
    List<Opportunity>opps = new List<Opportunity>();
    set<id>associatedAccid = new set<id>();
    for(Opportunity opp :trigger.new){
        associatedAccid.add(opp.AccountId);
        System.debug('associatedAccid'+opp.AccountId);
    }
    //Map<id,Account>Accmap=new Map<id,Account>
    opps =[Select id,Accountid,StageName,Account.Type From Opportunity Where Accountid =:associatedAccid];
    System.debug('Opportunity' +opps);
    for(Opportunity opp:opps){
        if(opp.StageName=='Closed Won-One Time'||opp.StageName=='Closed Won-Recurring'||opp.StageName=='Customer Reseller'){
            opp.Account.Type='Customer-Direct';
            accToupdate.add(opp.Account);
            System.debug('accToupdate'+opp.Account);
        }
        else{
            opp.Account.Type='Prospect';
           accToupdate.add(opp.Account);
        }
    }
    update accToupdate;
}