Discussions
- General Development
- Schema Development
- Apex Code Development
- Visualforce Development
- Formulas & Validation Rules
- Security
- Mobile
- Force.com Sites & Site.com
- Chatter Development
- Java Development
- .NET Development
- Perl, PHP, Python & Ruby
- Desktop Integration
- APIs and Integrations
- Visual Workflow
- Apple, Mac and OS X
- VB and Office Development
- AppExchange Directory & Packaging
- Salesforce Labs & Open Source Projects
- Other Salesforce Applications
- Jobs Board
- Force.com Discussion Boards
- :
- Developer Boards for Force.com and Database.com
- :
- General Development
- :
- populating a standard field with a custom field
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
populating a standard field with a custom field
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-16-2013 08:46 AM
Hi, i rewrote this post because I realized I wasnt being clear enough. Heres what im trying to do: when a lead is converted the parent account in lead needs to go over to the parent account in accounts. I found quickly that standard and custom fields cant be mapped together, but that a trigger could pull the data on conversion. I found a trigger here that I've attempted to use and I dont get any syntax errors with it, but when a lead is converted the parent account in accounts is left blank. Any help or suggestions would be appreciated, thanks!
heres the trigger:
trigger populateParentAccount on Account (before Insert){
List<Lead> convertedLeads=[SELECT Id, ConvertedAccountID, Parent_Account__c
FROM Lead WHERE IsConverted=True AND ConvertedAccountId IN :trigger.new];
Map<ID,ID> acctParentMap=new Map<ID,ID>();
for (lead l: convertedleads){
acctParentMap.put(l.ConvertedAccountId,l.Parent_Ac count__c);
}
for (account a:trigger.new){
if (acctParentMap.containsKey(a.Id)){
a.ParentID=acctParentMap.get(a.Id);
}
}
}
Solved! Go to Solution.
Re: populating a standard field with a custom field
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-17-2013 12:08 AM
Hi,
Try this:
trigger leadCheck on Lead (before update)
{
Map<Id, Id> convAccs = new Map<Id, Id>();
List<Account> accsUpd = new List<Account>();
for(Lead l:Trigger.new)
{
if(l.isConverted)
{
convAccs.put(l.ConvertedAccountId, l.Parent_Account__c);
}
}
List<Account> accs = [select ParentId,Id from Account where Id in: convAccs.keyset()];
for(Account a: accs)
{
a.parentId = convAccs.get(a.Id);
accsUpd.add(a);
}
update accsUpd;
}
Thanks
Re: populating a standard field with a custom field
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-17-2013 07:34 AM
thankyou! perfect

