You need to sign in to do that
Don't have an account?
Anas Alamour
Import CSV file in Flow and make some logic
I have requirement to upload csv file by salesforce Admin , the data in this csv file is not realted to one object on sakesfroce and coming from another system, read this file row by row , make some logic for each row , as an example , search of records by email address , if there is lead or contact record with the same email address , create new multiple standard and custom objects (parents and childs) , if no , just update that lead record.
Can this requirement be implemented by salesforce Flow , if so , please help me how to design that flow ? if not , can that be implemented by salesforce Apex ?
Can this requirement be implemented by salesforce Flow , if so , please help me how to design that flow ? if not , can that be implemented by salesforce Apex ?
Using Salesforce Flow:
Create a new flow in Salesforce Flow Builder.
Add a "Record Create" element to create new parent and child objects for standard and custom objects as needed.
Add a "Record Update" element to update the existing Lead record if no matching records are found.
Add a "Record Lookup" element to search for Lead or Contact records based on email address.
Use the "Loop" element to iterate through each row in the CSV file.
Add decision elements to check if a Lead or Contact record exists with the same email address, and based on the result, perform the desired logic.
Use the "Import CSV" element to read and parse the CSV file.
Map the fields from the CSV file to the corresponding fields in the objects being created or updated.
Save and activate the flow.
Using Salesforce Apex:
Create an Apex class that implements the logic to read and process the CSV file.
Use the Salesforce Apex CSV Parser library to parse the CSV file and retrieve the data.
Loop through each row in the CSV file and perform the desired logic, such as querying for existing Lead or Contact records, creating new parent and child objects, and updating existing Lead records.
Upload the CSV file using a Salesforce Visualforce page or a Salesforce Lightning Component.
Invoke the Apex class from the Visualforce page or Lightning Component to start the processing of the CSV file.
Save and deploy the Apex class and Visualforce page or Lightning Component.
Create an Apex class that implements the logic to read and process the CSV file. You can use the Salesforce Apex CSV Parser library to parse the CSV file and retrieve the data.
Upload the CSV file using a Salesforce Visualforce page or a Salesforce Lightning Component. You can create a Visualforce page with an HTML form to allow Salesforce Admins to upload the CSV file, or you can create a Lightning Component with a file upload component for the same purpose.
Invoke the Apex class from the Visualforce page or Lightning Component to start the processing of the CSV file. Call the processCSVFile method from the Apex class and pass in the parent object's Id and the body of the CSV file as parameters.
If you find my answer helpful, please mark it as the best answer. Thanks!