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
Satyavathi PolepallySatyavathi Polepally 

test class for a flow which updates the lookup field based on another field

Hi 

I need help to write a test class for a flow which updates the lookup filed on custom object based on the value of another field on the same object.

I have a custom object named Bank__c with lookup relation to Customer__c object. 
On the Bank__c object when Customer1__c text field gets updated with some value it should automatically populate a lookup field called Cust1__c on the Bank__c custom object itself.
I have created the flow to do this. Now I need help to write test class for this one.

Thanks in advance
ShirishaShirisha (Salesforce Developers) 
Hi Satyavathi,

Greetings!

You can insert the test record based on the Object and try to update the field as per your requirement in test class.

Also,please go through this blog (https://www.desynit.com/good-systems-blog/salesforce/writing-apex-tests-for-salesforce-flows-and-process-builders/) which will guide you to do the same with the sample code.

Kindly let me know if it helps you and close your query by marking it as best answer so that it can help others in the future.

Warm Regards,
Shirisha Pathuri