Generally apex batch jobs are scheduled to run at particular time intervals. But suppose we have a use case where we need to run the batch job on adhoc basis. We can call the batch apex from a screen flow in that case and the screen flow can be invoked from a button. So, the batch job can be executed on demand. Attached are the screenshots.
In apex, in order to get the current user role name we need to query the UserRole object. We cannot get it directly using UserInfo object since it has only one method related to role i.e getUserRoleId(). Using this Id returned we can get the data from UserRole object. But that is not that complex in flow. In case of flow, we can directly get the current user role name using the syntax: {!$UserRole.Name}. Attached are the screenshots.
We can pass list of Sobject records from LWC to flow as well. We need to define the list variable with @api to denote and expose as a public property in the flow. The meta file configuration remains the same i.e. define the property as @salesforce/schema/<SobjectApiName>[]. Attached are the screenshots.
Good One
ReplyDeleteNice
ReplyDelete