How can the default profile under which Webservices execute be changed?
Click on the arrows to vote for the correct answer
A. B. C. D.A.
The default profile under which webservices execute in Salesforce can be changed by using the "with sharing" keyword in the Apex class that defines the webservice method.
The "with sharing" keyword is used to enforce sharing rules that apply to the current user. By default, Apex code executes in system mode, which means that it has access to all data in the org, regardless of the sharing settings. However, when "with sharing" is specified, Apex enforces the sharing rules that apply to the user who is running the code. This means that the webservice method will execute under the permissions of the user who is invoking the method.
For example, consider the following Apex class that defines a webservice method:
javascriptglobal class MyWebService { webservice static String myMethod() { // do something } }
By default, this webservice method would execute in system mode, which means that it would have access to all data in the org, regardless of the sharing settings. However, if we add the "with sharing" keyword to the class definition, like this:
javascriptglobal with sharing class MyWebService { webservice static String myMethod() { // do something } }
Now the webservice method will execute under the permissions of the user who is invoking the method. This means that if the user has restricted access to certain data, the webservice method will also be restricted in its access to that data.
To summarize, the correct answer to the question is A: with sharing keyword.