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
Madhu DkMadhu Dk 

how to check Id is of which object/Sobject in Flow

Hi All,

i want to mimic this condition in Flow

if(m.UserOrGroupID.getsObjectType() == Schema.User.sObjectType){
                    tList.add(m.UserOrGroupId);
                }

i am not getting the option to check 'getsObjectType' or Schema.User.sObjectType in my flow decission 

please can any one guide me on this.

Thank you.
Best Answer chosen by Madhu Dk
AnudeepAnudeep (Salesforce Developers) 
There isn't any way to do that as far as I know directly in the flow.  I believe you have to Let Flows Execute Apex Actions. Going through this blog, I see this can be done through invocable action. GetObjectName invocable action specified in the blog post will do the job. 

All Answers

AnudeepAnudeep (Salesforce Developers) 
There isn't any way to do that as far as I know directly in the flow.  I believe you have to Let Flows Execute Apex Actions. Going through this blog, I see this can be done through invocable action. GetObjectName invocable action specified in the blog post will do the job. 
This was selected as the best answer
ShirishaShirisha (Salesforce Developers) 
Hi Madhu,

Greetings!

I don't think this is possible as the Flow can be created based on one Object and fires whenever the record is created,edited or when invoked by any other process.

You might need to use an apex class to achieve this and then invoke the same on process builder by using the invocable methods.

Example:https://www.desynit.com/dev-zone/salesforce-development/replacing-apex-triggers-processes-invocable-actions/

Kindly mark it as best answer if it helps so that it can help others in the future.

Warm Regards,
Shirisha Pathuri
James McLane 39James McLane 39
This is possible without Apex, if you don't mind a bit of manual work upfront.

Each object has a specific prefix (see here (https://www.salesforceben.com/salesforce-object-key-prefix-list/)) which can be incorporated into your Flow in various ways.

One option is to build these Object prefixes into a Custom Metadata Type (CMT) and then reference this CMT in the Flow using the Get Records Element. You would then loop over the CMT object to check your current RecordId against the table of prefixes.

Of course, you'll need to update the CMT if you have a need to reference new objects created after the CMT.