You need to sign in to do that
Don't have an account?
mukesh gupta
Hi Expert
Hi Expert,
I want to add Lead in Campaign, but i have a DML error.
Thanks
Mukesh
I want to add Lead in Campaign, but i have a DML error.
String searchItem = selectedValue; List<Lead> l = [SELECT id,leadsource FROM LEAD WHERE Name = :selectedValue]; String cname = l[0].leadsource; List <CampaignMember> cm = new list<CampaignMember>(); Campaign c = new Campaign(name = cname); insert c; CampaignMember cml = new CampaignMember(); cml.campaignid = c.id; cml.leadid = l[0].id; cm.add(cml); insert cm;Please suggest.
Thanks
Mukesh
All Answers
follow below code, Please check debug log.
Thanks
ContactId is Required field (ID of the Contact who is associated with a Campaign) in CampaignMember
this apex code is working fine in developer console. but when i select a lead from visualforce page dropdown list and click the button then get an error
Visualforce Error
System.LimitException: DML currently not allowed
Class.associateList.searchMethod: line 20, column 1
This is Apex code this is Visualforce page
I tried this it is working fine for me .if you can share the error i can try to help you
Thank you