function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Matthew LohMatthew Loh 

Process Builder to update parent account ID upon lead conversion

Hi everyone

Merry Christmas!!!

My org does almost all our sales from Parent (Partners), and as such every lead has a parent account attached to it. What I want to do is make it so that upon lead conversion, the parent account ID is automatically there in Account Stage.

As it stands, I cannot do custom field mapping from lead stage as the Parent Account (hierarchy) field is a default field.

So what I have done is mapped the Restricted Picklist of Parent_Account__c from lead stage to a restricted picklist called Parent_acc_mapped__c in Account Stage.

I then went to process builder and created a process where it executes the Object Account (when a new record is created or edited).

The criteria was:
Parent_acc_mapped__c ISNULL = FALSE
AND
ParentID ISNULL = TRUE
AND
parent_acc_mapped__c DOESNOTEQUAL ParentID
This is so that it only updates it for those converted from lead stage, whereas users who skip that and go straight to creating a new account can pick the parent account as they wish.

The action to be executed upon meeting those criteria are: 

Update a record
Parent Account ID FORMULA TEXT([Account].Parent_Acc_mapped__c )

I have made sure that every one of the picklist options that can be selected are already Accounts themselves so that they can be made Parents.

However upon activating this process and testing a lead conversion, I get this error:
 
Error: System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_EXECUTE_FLOW_TRIGGER, The record couldn’t be saved because it failed to trigger a flow. A flow trigger failed to execute the flow with version ID 3016F000000Xjcv. Flow error messages: <b>An unhandled fault has occurred in this flow</b><br>An unhandled fault has occurred while processing the flow. Please contact your system administrator for more information. Contact your administrator for help.: [] Class.leadconvert.BulkLeadConvert.handleRegularAccountInserts: line 226, column 1 Class.leadconvert.BulkLeadConvert.convertLead: line 88, column 1


As seen in the image : 
User-added image

I suspect it has something to do with the fact that Parent Account is an ID field and my picklist is, well, a picklist.

I normally use the REFERENCE field__c instead of FORMULA TEXT(field__c), but in this case it didn't allow me since one was an ID field and the other was a picklist.

Any ideas on how this can be solved? It is tedious having to update the Parent Account of each account individually upon lead conversion.

I tried writing an Apex trigger in my Developer Edition as referenced in my other post here https://developer.salesforce.com/forums/ForumsMain?id=9060G000000XiSjQAK but upon running it, nothing happened upon lead conversion. It's as if nothing changed.

Would appreciate any advice on this please! :)

Once again, Merry Christmas!!!

Best Answer chosen by Matthew Loh
Akhil AnilAkhil Anil
Hi Mathew,

Can you post what values do you have in the Parent_Acc_mapped__c field ? The ParentId field in the Account is a lookup field and will only hold values of the type ID and it should be an 18 character ID of a valid Account record in your organization. I feel that the Parent_Acc_mapped__c field in your Account do not hold these ID values and hence it's throwing this error.

All Answers

Akhil AnilAkhil Anil
Hi Mathew,

Can you post what values do you have in the Parent_Acc_mapped__c field ? The ParentId field in the Account is a lookup field and will only hold values of the type ID and it should be an 18 character ID of a valid Account record in your organization. I feel that the Parent_Acc_mapped__c field in your Account do not hold these ID values and hence it's throwing this error.
This was selected as the best answer
Matthew LohMatthew Loh
Hi @Akhil

So for example one of the options in the custom picklist Parent_Acc_mapped is "Direct".

These are just text values, and not the Account IDs that you mentioned so yeah I guess that's why the error exists.

I thought ParentID field in Account Stage was text.

Any ideas on how I can make the Parent_Acc_mapped mirror the ParentAccount ID?

Maybe if I made a field which populated itself with the appropriate ID based on what was select in the Parent_acc_mapped picklist, and then used process builder to reference Parent ID with the correct ID from that populated ID Field?

So the way it would work is:
1) Lead Stage 
a) Select Parent Account from that restricted picklist
b) Process rule to update Custom ID field based on the already existing Account IDs.

2) Account stage
Create process to update the parent account ID with that of the Custom ID field as soon as the Account is created/existed, so that there is no need to manually do it.

Only problem is, I can't figure out how to create a custom field whose format is ID. I only see stuff like Number/Currency/Text/etc.

 
Matthew LohMatthew Loh
Hi @Akhil

I just tried it using a usual text field and it works! It doesn't necessarily have to be an ID Field.

I just set the update to be Parentid FORMULA = Custom_text_field__C which contains the parent account ID.

Now all I have to do is make an IF function to generate the applicable account IDs for that field before conversion :)

Merry Christmas!!! :)
Charles Hill 8Charles Hill 8
Great post. I'm just about to set this up as well. Thanks for the head start!