Tell me more ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

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?

share|improve this question

1 Answer

up vote 3 down vote accepted

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','...');
share|improve this answer
Created One Sharing Reason with Label "Test Reason" and am using the above code only. I am Getting the following error : Row Cause: bad value for restricted picklist field: Test Reason;getStatusCode=INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST – Avidev9 Oct 3 '12 at 19:39
Sounds like your entering it with a space in the label. The label should have underscores, or no spaces. So maybe something like: TestReason__c or Test_Reason__c – jordan.baucke Oct 3 '12 at 19:40
Well sorry forgot to reply, Rowcause should be the API name for the Apex Sharing Reason. – Avidev9 Nov 27 '12 at 13:33

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.