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
salesforce sfdxsalesforce sfdx 

Hi Team, can any one help me to resolve the lightning Flow

Requirement using a Flow: but flow is not Working.

UseCase:
When the lead record is converted.
lead record  details are to be updated in the account object.
created a same fields in both objects but when we run the flow it was showing Error.

 
Result
Failed to update records that meet the filter criteria.

Error Occurred: 
This error occurred when the flow tried to update records: SELECT Id FROM Account WHERE ((Id = ' 0012h00000oEq2cAAC')) LIMIT ^ ERROR at Row:1:Column:32 invalid ID field: 0012h00000oEq2cAAC. You can look up ExceptionCode values in the SOAP API Developer Guide.


 
Flow Steps :

Step 1: Start
a.Created a Record -Triggered Flow on lead
b.A record is Created or Update
c.optimize for: Actions and Related Records.

Step 2: Decision
a)Yes
b)All conditions met
c)Conditon:
{!$Record.IsConverted}   Equals  {!$GlobalConstant.True}


Step 3: update the lead data on the convertedAccountid Record.
a)Specify conditions to identify records, and set fields individually
b)Object: Account.
c)All conditions met.
d)Conditon:
Id  Equals   {!$Record.ConvertedAccountId}

e)Set Field Values for the Account Records

Manufacturer__c  <-- {!$Record.Manufacturer__c}

Step 4:End.

Note: Manufacturer__c   is a custom field in the salesforce.

Please  suggest a better way to handle it , 
thanks
sfdx 
 

 
Best Answer chosen by salesforce sfdx
Sai PraveenSai Praveen (Salesforce Developers) 
Hi,

This is expected behaviour of salesforce.Please find the below lines from the article (https://help.salesforce.com/s/articleView?id=sf.leads_notes.htm&type=5) mentioned.
If existing accounts and contacts share the names specified on the leads, you can choose to update the existing accounts and contacts. Salesforce adds information from the lead into empty fields; Salesforce doesn’t overwrite existing account and contact data.

I hope this answers your question.

If this solution helps, Please mark it as best answer.

Thanks,
 

All Answers

Sai PraveenSai Praveen (Salesforce Developers) 
Hi,

As we have standard lead mapping where we can map the custom lead field with the Account or Contact or opportunity fields. I hope the flow is not at all required in this scenerio.

Please find the below article for the same

https://help.salesforce.com/s/articleView?id=sf.customize_mapleads.htm&type=5 (https://help.salesforce.com/s/articleView?id=sf.customize_mapleads.htm&type=5)

If this solution helps, Please mark it as best answer.

Thanks,
 
salesforce sfdxsalesforce sfdx
Hi Thanks for the information,
 i had tried with the standard mapping conditions but it was not working , Do you have any idea to debug that issue.
 as it was not working so started working with flow to acheive the issue.
Can u please let me know any better solution to debugging the mapping values is mapped or not.
Thanks
Sfdx
Sai PraveenSai Praveen (Salesforce Developers) 
Hi,

You can check if it is mapped or not like below.

Go to Setup-> ObjectManager-> Lead->Field and Relationship-> Map Lead Fields button

User-added image


Let me know if you need any details.
Thanks,
 
salesforce sfdxsalesforce sfdx
Hi Praveen , thanks for the quick reply, as per above comments i had done it already but something issue after the mapping.

In lead the customfield Manufacturer__c is a picklist value.
In Account the customfield Manufacturer__c is a Global Value Set of  CGM_Manufacturer ,
Restrict picklist to the values defined in the value set is set as "True" be default for above Account manufactorer picklist value,
if using the Gobal value set picklist in account , will it throw an error

Other Test Approach From Developer console:
   
account a =[select id,name from account where id ='0018I000009MwsDQAS'];
 
 account ac = new account();
  ac.id= a.id;
  ac.Manufacturer__c='Nexon';
  system.debug(ac);
  update ac;


Error in Developer Console:

System.DmlException: Update failed. First exception on row 0 with id 0018I000009MwsDQAS; first error: INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST, bad value for restricted picklist field: Nexon: [Manufacturer__c]
 
Sai PraveenSai Praveen (Salesforce Developers) 
Hi,

Did you check if Nexon value is present in GlobalValueset which is used and is the spelling same?

Thanks,
 
salesforce sfdxsalesforce sfdx
Hi , 
Yes i have checked it was the same.

let me Explain the Issue iam facing.
1)Lead>Manufacturer__c  is  a picklist value
2)Account >Manufacturer__c> is a Global picklist Value set.
Global picklist Value set contains [Nexon,Dexon]
When i convert an lead  and Ex: it has Manufacturer__c ='Nexon' 
a) if the account  object Manufacturer__c is Empty or null it was updating and Working fine as expected..
b)if the account has any field value like:
  account>Manufacturer__c ='Dexon' ,then it was not updating to 'Nexon'.

Note: if the accout field value is empty , standard functionality is working fine as expected
when account filed has any default value, it was not replacing it. 
Stucked in it.

Thanks
Sai PraveenSai Praveen (Salesforce Developers) 
Hi,

This is expected behaviour of salesforce.Please find the below lines from the article (https://help.salesforce.com/s/articleView?id=sf.leads_notes.htm&type=5) mentioned.
If existing accounts and contacts share the names specified on the leads, you can choose to update the existing accounts and contacts. Salesforce adds information from the lead into empty fields; Salesforce doesn’t overwrite existing account and contact data.

I hope this answers your question.

If this solution helps, Please mark it as best answer.

Thanks,
 
This was selected as the best answer
salesforce sfdxsalesforce sfdx
Hi thanks for your help may i know the solution to get this Task done, should i have to Proceed with Trigger for updating or replacing the account record with the lead details
Thanks
sfdx
Sai PraveenSai Praveen (Salesforce Developers) 
Hi,

Yes Can you try the below trigger on lead object and it will update it.
 
trigger mapping on Lead (after update) {
    List<Account> AccList = new List<Account>();
    for(Lead ll:Trigger.New) {
        if(ll.isConverted==true && ll.ConvertedAccountId != null) {
            Account acc = new Account(Id = ll.ConvertedAccountId, Manufacturer__c =ll.Manufacturer__c );
            AccList.add(acc);
        }
    }
    update AccList;
}

If this solution helps, Please mark it as best answer.

Thanks,
salesforce sfdxsalesforce sfdx
Thank you praveen, so it cannot be done with standard functionality it seems , 
Thanks for your info.Thanks
salesforce sfdxsalesforce sfdx
Marked it as Best Answer