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
nik9000nik9000 

s-control permission problem

Hopefully there is an easy solution to this and I am just missing it.
 
For our company, we have Leads sent to a single user, as a generic pool, that others can come and claim Leads from (like a pool).  This pool user recently had some restructuring done to it, so that some people within the company do not have permissions to change the owner id to themselves (which is good and bad).  I want to create a hyperlink to an S-control on certain profiles to change the ownerid from the lead to the person that is logged in.  I did it (code below) but ran into a similar problem.  For admins and people with permission to claim a lead from the pool, everything works, but for any user that does not have access, the s-control will fail.  What I am looking for is a way to override this permission and allow this user to claim a lead from the pool.  My first instinct was to just post the URL to an offsite servlet and log in as an admin and just handle all the objects there, but I would ideally like to keep this confined as an S-Control.  Is this possible?
 
  this is the code that I used. I know the line that fails, and why it fails. I am just looking for a workaround that doesnt leave salesforce, if possible.
 
 
function startup() {
try{
if( '{!Lead.OwnerId}' == "00530000000fZ61") {
   var lead = new sforce.SObject("Lead");
   lead.Id = "{!Lead.Id}";
   lead.OwnerId = "{!$User.Id}"; //this fails
   var updateResult = sforce.connection.update([lead]);
   if(updateResult[0].getBoolean("success")) {
      return updateResult[0].id;
   } else {
       alert("Could not claim:\n\nError:\n"+updateResult[0]);
   }
}
window.close();
}catch(e){alert('update failed '+e);} }
 
window.onload = startup;
Greg HGreg H
I am sure you have good business reasons for what you're doing but have you looked into lead queues?  They might apply to your needs here.
 
Anyway, the problem is with your Profile permissions.  If you are restricting the reassignmnet of leads as a profile setting then your sControl cannot override that setting.
 
A possible work-around could be to update the Profiles for non-admins so that they can reassign leads, but hide the Leads tab from those users.  Then build another sControl to display a list of leads from which your users can pull the ones they need.
 
By hiding the tab, you essentially eliminate your users' ability to see and search for that Lead data.  But by setting the Profiles with Read, Edit, Create permissions on the Leads object you can still allow them to reassign.
-greg