+ Start a Discussion

urgent: Trigger not updating lookup field with web-to-lead form

Hey All , 


I apologize for posting this post again as this  issue is still bothering me. Kindly help me with the below problem .


So , I have these 3 fields :- 1.) Primary distrubutor( picklist and controlling field)

                                                  2.) Primary distriibutor systemID (18 digit ID,  Picklist , controlled by Primary Distributor )

                                                  3.) Preferred Distributor .....( look up field to accounts and equals to primary distri. systemID)


In the Web to lead form , Users can select the Primary distributor . But when I go back to check the SFDC there are no value update in Primary distriibutor systemID & Preferred Distributor. Below is the code.This code just works perfectly when I am entering the lead through SFDC . 


trigger LeadTrigger on Lead (before insert , before update) {
if(trigger.isBefore) {
    if(trigger.isInsert || trigger.IsUpdate) {
      for(Lead l : trigger.new) {
        if(l.primary_sysid__c != null) {
          l.preferred_distributor__c = l.primary_sysid__c;

Posting this twice isn't going to get you help any faster. If you look at the last thread you started you can see I had asked you another question within there, that you still haven't answered.


Hey , 


I sincerely apologise as I never noticed your reply . I thought you didnt reply thats why I posted again. forgive me .


Yeah , I am not getting any error . The error was due to some invalid fields. But it is not updating lookup field( preferrred distributor) After I click on EDIT on LEAD record then only it updates the primary distributor sysid field and preferred distributor (lookup) field. I want as soon as lead enters  its information and selects the primary distributor in web to lead form the lookup field should automatically be updated with the help of trigger. But this is not happening.