You need to sign in to do that
Don't have an account?
Sam Ward
why wont my lead update
Hi,
I have the below code but for some reason it will not find the lead to update.
I'm making sure my URL has ?id=00Q3H000002GWoIc but it just seems to ignore this I think its because it can't find it. Then does the page redirect as I want it to.
Any feedback or direction where to look would be greatly appericated.
Thanks
I have the below code but for some reason it will not find the lead to update.
I'm making sure my URL has ?id=00Q3H000002GWoIc but it just seems to ignore this I think its because it can't find it. Then does the page redirect as I want it to.
public with sharing class SurveyRedirect { public String ObjectId {get;set;} public String ResponseCode {get;set;} public SurveyRedirect () { ObjectId = ApexPages.currentPage().getParameters().get('ObjectId'); ResponseCode = ApexPages.currentPage().getParameters().get('ResponseCode'); } public PageReference onLoad() { List<Lead> Lead = [SELECT Id, Cars__c FROM Lead WHERE Id=:ObjectId LIMIT 1]; if(!Lead.IsEmpty()){ Lead[0].Cars__c = True; UPDATE Lead; } PageReference pr = new PageReference('http://www.google.com'); pr.setRedirect(true); return pr; } }
Any feedback or direction where to look would be greatly appericated.
Thanks
List<Lead> Lead = [SELECT Id, Cars__c FROM Lead WHERE Id=:ObjectId LIMIT 1];
All Answers
If this answer helps you, please mark it as accepted.
Regards,
Tushar Sharma
https://newstechnologystuff.com/
Also, remove the ResponseCode, you are not using it as I can see.
If it helps please mark as correct, it may help others.
I think i will use the response code I do have it commented out for the moment though thank you
Also use a system.debug(ObjectId); on line 7 to see if you are getting any value.
I also recommend to put system.debugs on line 10 to see if the onLoad is being executed.
If it helps please like or mark as correct, it may help others.
List<Lead> Lead = [SELECT Id, Cars__c FROM Lead WHERE Id=:ObjectId LIMIT 1];