You need to sign in to do that
Don't have an account?

Trigger not working with web to lead
Hey All ,
I have Trigger on Lead which is updating look up field . Its working fine when I create a lead through SFDC . But , when I use web to lead form to enter lead , Trigger is not updating look up field. Any suggestions what could be the reason ??
Regards
Hmm... It should work just fine, can you post your trigger code so I can see how it works?
So , I have these 3 fields :- 1.) Primary distrubutor( picklist and Independent field)
2.) Primary distriibutor systemID (18 digit ID, Picklist , controlled by Primary Distributor )
3.) Preferred Distributor .....( look up field on 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.
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;
}
}
}
}
}
Yeah, you're going to have to set the Primary Distributor System ID either in the Web-To-Lead form, or within a trigger. Dependent picklists won't default a value for you on Web-To-Lead. All that is done within Salesforces interface via javascript.
Hey ,
Can you throw little light on it because I took the Primary distrubutor systemID field in th web to lead form but when I execute the hTML code it gives ERROR. And , How can it be done interfacing with javascript ???
Regards
What error does it give you?
I am posting the code to w3schools.com ( just to check) . It only says ERROR , THATS IT ...
In the web form are you setting a value for the Preferred Distributor System Id?
yES ..Below is the HTML Code
<!-- ---------------------------------------------------------------------- -->
<!-- NOTE: Please add the following <META> element to your page <HEAD>. -->
<!-- If necessary, please modify the charset parameter to specify the -->
<!-- character set of your HTML page. -->
<!-- ---------------------------------------------------------------------- -->
<META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8">
<!-- ---------------------------------------------------------------------- -->
<!-- NOTE: Please add the following <FORM> element to your page. -->
<!-- ---------------------------------------------------------------------- -->
<form action="https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8" method="POST">
<input type=hidden name="oid" value="00Di0000000Ho9r">
<input type=hidden name="retURL" value="http://">
<!-- ---------------------------------------------------------------------- -->
<!-- NOTE: These fields are optional debugging elements. Please uncomment -->
<!-- these lines if you wish to test in debug mode. -->
<!-- <input type="hidden" name="debug" value=1> -->
<!-- <input type="hidden" name="debugEmail" -->
<!-- value="citm.tushar.27@gmail.com"> -->
<!-- ---------------------------------------------------------------------- -->
<label for="last_name">Last Name</label><input id="last_name" maxlength="80" name="last_name" size="20" type="text" /><br>
<label for="company">Company</label><input id="company" maxlength="40" name="company" size="20" type="text" /><br>
primary_sysid:<select id="00Ni0000000Tvq0" name="00Ni0000000Tvq0" title="primary_sysid"><option value="">--None--</option><option value="11111">11111</option>
<option value="22222">22222</option>
<option value="33333">33333</option>
<option value="44444">44444</option>
<option value="55555">55555</option>
<option value="66666">66666</option>
<option value="77777">77777</option>
<option value="88888">88888</option>
<option value="001i0000001wzvZ">001i0000001wzvZ</option>
<option value="00Qi0000001SIUf">00Qi0000001SIUf</option>
<option value="001i0000001wzvy">001i0000001wzvy</option>
<option value="001i0000002sObc">001i0000002sObc</option>
<option value="001i0000001xBy9">001i0000001xBy9</option>
<option value="001i0000001xC6c">001i0000001xC6c</option>
</select><br>
primary distributor:<select id="00Ni0000000Tvq5" name="00Ni0000000Tvq5" title="primary distributor"><option value="">--None--</option><option value="abc">abc</option>
<option value="def">def</option>
<option value="ghi">ghi</option>
<option value="jkl">jkl</option>
<option value="mno">mno</option>
<option value="pqr">pqr</option>
<option value="stu">stu</option>
<option value="vwx">vwx</option>
<option value="mayur">mayur</option>
<option value="Arrow">Arrow</option>
<option value="Burlington Textiles corp of America">Burlington Textiles corp of America</option>
<option value="mayur(NA)">mayur(NA)</option>
<option value="Tushar (NA)">Tushar (NA)</option>
</select><br>
<input type="submit" name="submit">
</form>
Just tested your form and submitted a value without getting any error... Where exactly are you receiving this error?
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.
Regards
Hrmmm... this is odd behavior. Can you do me a favor and try running this as your trigger code and tell me if you get the results you're looking for.
Hey , Thanks for the reply .
I tried this code.
1.) when I use web to lead , no updates are taking place i.e primary distributar sysid__c and preferred distributar fields are not getting updated.
2.)second case , When I use SFDC to insert new lead it is giving me this error
Apex trigger LeadTrigger caused an unexpected exception, contact your administrator: LeadTrigger: execution of AfterInsert caused by: System.FinalException: Record is read-only: Trigger.LeadTrigger: line 10, column 1
3.) And , When I am using SFDC to update exsisting record it is working fine.
Regards
Hey Jonathan ,
Do you have any idea how to fix the above errors in the code that you gave me ??
Regards