Find your content:

Search form

You are here

Assign sharing reasons from Dynamically from APEX

 
Share

Was wondering if there is way to assign the Sharing Reason aka Rowcause Dynamically. Well tried to implement using this "Schema.MyCustomObject__Share.rowCause.My_Sharing_Reason__c" but here I have to fix the sObject and the reason. Is there anyway to assign them dynamically?


Attribution to: Avidev9

Possible Suggestion/Solution #1

You can't assign them completely dynamically.

You need to create them from the point and click interface (Setup->Create->Object Name->Apex Sharing Reasons) or via the meta-data api.

myObject__share share = new myObject__share();
share.put('RowCause','APIOfMyApexSharingReason__c');
share.put('ParentId','...');

Attribution to: jordan.baucke
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/1915

My Block Status

My Block Content