+ Start a Discussion
BAGELBAGEL 

Frustrating... need help badly.

Hi everyone,

 

I am trying to fix my s-control. Currently I ran into two issues. I have the following code:

 

var icon = sforce.connection.query("Select d.id from Document d where Name='SCMgr Icon'").records.Id;
var tab = sforce.connection.query("Select w.id from WebLink w where Name='SalesAdvisor'").records.Id;
var trans = sforce.connection.query("Select d.id from Document d where Name='onepixel'").records.Id;

 

it works perfectly when I logged in as System strator profile.

 

however, when I logged in as Standard User profile, it doesn't.

more interestingly, I get value for icon, but I get undefined for tab and trans.

I can go to the document section and open SCMgr Icon and onepixel just fine.

 

If anyone can help, I will be very much appreciated. Thanks.

Best Answer chosen by Admin (Salesforce Developers) 
Yagna_DevYagna_Dev

The real problem is a field that I referenced in the VF page.

 

I get this error if I login as another user (any user other than System Admin) and that user does not have read access to that field.

 

Fix: Query that field in the controller and use getter and setters to reference it on the VF page

All Answers

aalbertaalbert

That is because an SControl runs in the context of the authenticated user, in this case the Standard User. And the Standard User is probably not able to query the WebLink and possibly the specific Document you are querying for. It works for the Admin since an Admin can view all data.

 

Is it possible to redesign the solution to use Visualforce and Apex? You can accomplish all of this with those technologies on the force.com platform.

 

 

 

BAGELBAGEL

Eventually, we will have to, but I need a solution or workaround quick though. Any suggestions?

BAGELBAGEL

Hmm. it doesn't look like Standard User does not have access to those resource.

 

I can see/access to that tab and that document manually just fine.

 

Only when I do a sforce.connection.query that gives me a problem. :(

SteveBowerSteveBower

The access construct you're using (   s.c.q('querystring').records.id;   ) assume that there will only be one record returned from each query.  I don't know if that's the case, but a 'Limit 1' added to the query would ensure it.

 

My first bet however would also be security restrictions, just because of how you're describing it.

 

Are you throwing any errors?  Checking the return codes for the queries to see if there are any errors, etc.?   Does anything show up in the Javascript console?

 

Best, Steve.

BAGELBAGEL

I got undefined from thoese queries.

BAGELBAGEL

Kinda found the issue, but not sure why.

 

The option I need to check on Profile is "Customize Application". Once I have this option checked, the query works fine.

aalbertaalbert

The issue is that the SControl executes the queries under the logged in user's access controls as defined in sharing and profile settings. Additionally, any user whose Profile doesn't have the Customize Application permission enabled will not get the WebLink records via the query since they don't have visiblity to query that object's records. Depending on the document sharing, the user might not even have access to the Document you are querying in the SControl.

 

 

Yagna_DevYagna_Dev

I have a VF page that has loads of Javascript. This javascript works fine when I login as a system admin but does not work with other profiles.

I figured that its because of "Customize Application" permission for a profile.

Based on the documentation tried giving edit permission on all the fields that I am querying in the extension class, but it does nothing.

I commented the queries that query AccountContactRole and OpportunityContactRole objects but nothing happens. I still get this error whenever an actionFunction is invoked.

 

 

ERROR	
Error:
 j_id0:parentFormId_Dummy:j_id95: An error occurred when processing your submitted information.

 

 

Yagna_DevYagna_Dev

The real problem is a field that I referenced in the VF page.

 

I get this error if I login as another user (any user other than System Admin) and that user does not have read access to that field.

 

Fix: Query that field in the controller and use getter and setters to reference it on the VF page

This was selected as the best answer