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

Create Manual Sharing

Hello Everyone
I'm trying to create a list button that will apply manual sharing on multiple records  (kind of like what the "Change owner" button is doing).
I've tried to directly create records in the "Object__Share" table. Here is the code:
<script src="/soap/ajax/11.1/connection.js"></script>
<script src="/desktop/desktopApi.js"></script>

// Create an instance of a custom_object
var new_Custom_Object = new sforce.SObject("Class_Registraion__Share");

new_Custom_Object.ParentId = {!$User.Id};
new_Custom_Object.AccessLevel = 'Read';
new_Custom_Object.RowCause = 'Rule';// change value of object
new_Custom_Object.UserOrGroupId = '00G30000000hMJkEAM'; 

// Create the Object
  var saveResult = sforce.connection.create( new_Custom_Object );
  // Check to see that the object was created successfully
  if ( saveResult[0].getBoolean("success") )
     alert( "Success  " );
    alert( "Error occurred: " + saveResult[0] );
<body onload="init()">

when i run this nothing happens - it just giving me blank screen...
I've also tried using {Action.Object__c.Sharing} inside an s-control or directly on the button with "Execute Javascript" but i cannot seem to get it work.
does anyone have any expirience with it or did something similar?
Any answer will be much appriciated
Of course it gives you a blank screen; your Scontrol renders nothing but a blank screen.  If you want it to render something you have to add something in the <body> tag, or add some JS that navigates to a different page.  Remember that an Scontrol is really just a regular old HTML page, and it will only render whatever HTML you put in it.

Note that you probably have a misspelling in there:

Should be:

And I'm not sure it's going to let you set a RowCause of Rule.  You should probably run this with Firebug to see if you get any errors with it and step through it.

thanks for your response. i'll try debugging it with firebug. (and sorry for the red fonts - my spelling tool got out of hand :smileyhappy:)