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
sai.sfsai.sf 

sforce.connection.query

Hi All,

  

   sforce.connection.query('Select Name,Id from Account where Name=xyz') returns only records that are accesseble to user in button.So the query returns not same results to all users.how to retreive all records from the query?

 

Thanks

 

Best Answer chosen by Admin (Salesforce Developers) 
Andy BoettcherAndy Boettcher

All Answers

Anup JadhavAnup Jadhav

What do you mean by "records that are accesseble to user in button"? 

 

If you look at the SOAP documentaton for the query() method, it clearly states that:

 

Your client application must be logged in with sufficient access rights to query individual objects within the specified object and to query the fields in the specified field list. For more information, see Factors that Affect Data Access.

 Check out the Factors that Affect Data Access.


Hope this helps!

 

- Anup

Andy BoettcherAndy Boettcher

This is a result of Sharing Rules in your org.  To bypass sharing rules, remove the "with sharing" keyword from your APEX class definition.

 

Also - make sure that is REALLY what you want to do, Sharing Rules are typically there for a reason!

 

-Andy

Anup JadhavAnup Jadhav

Hi Andy,

 

I suspect that "with sharing" will solve his problem. He doesn't state it explicitly but "sforce.connection.query" indicates that the request is made via the webservice somewhere in a client application.

 

- Anup

sai.sfsai.sf

i am using webservice class.I am not using ' with sharing' keyword in my class .I don't know why i am getting soql results different per user?

Anup JadhavAnup Jadhav

Hi Sai.sf,

 

Like I said look at the link that I've provided in my reply. Go through that list, and eliminate each possibility one by one. It is most probably down to field permissions, and roles.

 

- Anup

Andy BoettcherAndy Boettcher
This was selected as the best answer
sai.sfsai.sf

Thanks Andy  & Anoop for your valuable inputs that helped in fixing the error.