Flow is part of salesforce flows which collects data via user screens from business users inside your salesforce organization or we call as ORG hereafter .
Salesforce flows comes in two flavors
a) Screen flows
b) Auto launched flows
Screen flows are used in business scenario where data is collected from users screens. Auto-launched flows runs in background which are triggered or launched automatically based on certain system conditions . That is a bit of basis check on flows .
The article is written with a specific scenario to be discussed which is how we can validate and check if a record has file attached in files related list . We will be using low code salesforce automation mechanism called Flows in this scenario .
Business Use case :
SFAGile is cloud based company which helps its customers to
publish its application into salesforce cloud . Business users have a requirement where they need to validate salesforce records against training documents are attached to the case when record is created . We need to make sure salesforce record is not progressed to next state in the workflow without training forms attached by employees.
The requirement could be built using salesforce trigger which is programmatically driven approach or using low code mechanism like Salesforce flows .
The final flow diagram post implementation of the logic :
The getRecords Element :
Decision Elements :
Decision element if false :
Decision element if True :
Update Records Element if Decision is False
Update Records Element if Decision is true
Here we have created a validation rule on field : hasAttachedFile__c .
If hasAttachedFile__c is set to True it means file is attached to the record and record can progress to next state .
If hasAttachedFile__c is set to false it means file is NOT attached to the record and record cannot progress to next state .
Flow explanation :
We need to have a record triggered flow ( after save) flow on the record. The relationship between a record and a file is kept in a contentdocumentlink object in salesforce. We need to right a logic to get if there are any content document link that is related to object that the end user is trying to save. If there are not any files attached to the record we can save the intermediate results to a field and then trigger a validation rule to stop record being progressed .
Your get element should look like this:
Object: Content Document Link
LinkedEntityId equals Record.Id
Later check if there are any content document link are available or not. Your decision outcome should be configured as ::
getcontentdocumentlink is null true
If the outcome results is null, you need to connect the output of decision outcome to an update element so we can trigger validation rule .
Comments
Post a Comment