• rushi ettam 7
  • NEWBIE
  • 30 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 5
    Replies
In Apex code Developers Guide
If we are using with and without sharing rules in our Apex class
We see the following:
Enforcing the current user's sharing rules can impact:
• SOQL and SOSL queries. A query may return fewer rows than it would operate in a system context.
• DML operations. An operation may fail because the current user doesn't have the correct permissions. For example, if the user
specifies a foreign key value that exists in the organization, but which the current user does not have access to.

Actually what is the sharing rule:  it provides the wider access to data
So, my Question here is:  how can  SOQL and SOSL queries return fewer rows
it has to return more rows because sharing rules provide additional access
and even with the ​ DML operations also we shouldn't get the error while performing any DML.

Thanks in advance.......


 
Hello,
  This is a vf page, trying to get &set the  query string parameter
The page compiled successfully and showing the list of related contacts but when I click the contact name link the following error occurs
Insufficient Privileges
You do not have the level of access necessary to perform the operation you requested. Please contact the owner of the record or your administrator if access is necessary. For more information, seeInsufficient Privileges Errors. 

<apex:page standardController="account">
  <apex:form >
   <apex:pageBlock title="contacts" >
    <apex:pageBlockTable value="{!account.contacts}" var="ca">
     <apex:column headerValue="Name" >
      <apex:commandLink > {! ca.name}
       <apex:param name="cid" value="{ca.id}"/>
       </apex:commandLink>
       </apex:column>
      <apex:column value="{!ca.email}"/>
    </apex:pageBlockTable>
   </apex:pageBlock>
   <apex:detail subject="{!$CurrentPage.parameters.cid}" relatedList="false"/>
  </apex:form>
</apex:page>

Anyboby have solution for this problem???????
Hello,

I created one class to upsert using databse,but it is only inserting new records in the object not updating
and the test class code coverage is 88% one line is not covering i.e   acc.sic = 'atlanta'; 
can anybody resolve this issue?

public class upsertAccount{
  public static List<Database.upsertResult> upsertAcc(){
    List<Account> acclist = [select id,name,Billingcity,sic from Account where Billingcity = '' ];
    for(Account acc:accList){
      acc.sic = 'atlanta';
      //acclist.add(acc);
    }
    Account newAcc = new Account(name='Acme',Billingcity= 'San Fransicso');
    acclist.add(newAcc);
    Schema.SObjectField schemaField = Account.Fields.SLASerialNumber__c;
List<Database.upsertResult> Results = Database.upsert(acclist ,schemaField ,false);
   return results ; 
  }
 }

Test class

@isTest
public class testUpsertAccount{
  public static testmethod  void testDatabseupsert(){
  List<Database.upsertResult> results =  UpsertAccount.upsertAcc();
  for(Database.upsertResult result:results ){
  system.assert(result.issuccess());
}  
  }
}

Thanks,
Rushi
Compile Error: Invalid type: Databse.UpsertReuslt at line 10 column 5

I got the above error when trying to use the upsert using database class.Plz anybody have solution for this?

public class upsertAccount{
  public static List<Database.upsertResult> upsertAcc(){
    List<Account> acclist = [select id,name,Billingcity from Account where Billingcity = '  ' ];
    for(Account acc :acclist ){
      acc.Billingcity = 'atlanta';
    }
    Account newAcc = new Account(name='Acme',Billingcity= 'San Fransicso');
    acclist.add(newAcc);
    //upsert(accList);
    Databse.UpsertReuslt[] result = Database.Upsert(acclist ,false );
  }
}

Thanks in advnace....
 
I mentioned my return type as Contact in my method
until you specify that Contact record with DML statement it won't save to database
and if you won't specify systm.debug , we can't see the output in debug log
But if you are not using the DML statment and system.debug
How &&Where can you use the returned values from any method in apex class???????
in Apex Basics&Database SOSL Queries
We have challenge to pass the string parameter as input and depend upon that string made sosl query
but in reality how can you make that
searchQuery in SOSL accept text search
syntax as find 'smith' in all fields

So the question is how can we put the variable name in place of string???
I wonder Standard objects Account,Lead and Opportunity  had address fields and their data type is "ADDRESS"
In custom objects, if you want to create address field
how can you create them??
 
how to set the opportunity stage picklist field in Flow
Can anybody explain in detail..........

Thanks in advance
Rushi
In Apex code Developers Guide
If we are using with and without sharing rules in our Apex class
We see the following:
Enforcing the current user's sharing rules can impact:
• SOQL and SOSL queries. A query may return fewer rows than it would operate in a system context.
• DML operations. An operation may fail because the current user doesn't have the correct permissions. For example, if the user
specifies a foreign key value that exists in the organization, but which the current user does not have access to.

Actually what is the sharing rule:  it provides the wider access to data
So, my Question here is:  how can  SOQL and SOSL queries return fewer rows
it has to return more rows because sharing rules provide additional access
and even with the ​ DML operations also we shouldn't get the error while performing any DML.

Thanks in advance.......


 
Compile Error: Invalid type: Databse.UpsertReuslt at line 10 column 5

I got the above error when trying to use the upsert using database class.Plz anybody have solution for this?

public class upsertAccount{
  public static List<Database.upsertResult> upsertAcc(){
    List<Account> acclist = [select id,name,Billingcity from Account where Billingcity = '  ' ];
    for(Account acc :acclist ){
      acc.Billingcity = 'atlanta';
    }
    Account newAcc = new Account(name='Acme',Billingcity= 'San Fransicso');
    acclist.add(newAcc);
    //upsert(accList);
    Databse.UpsertReuslt[] result = Database.Upsert(acclist ,false );
  }
}

Thanks in advnace....
 
Hi there,

I basically want to take the value of one date field and send that value to another date field.

The second date field should still be able to be customised though.

Any help would be much appreciated.

regards

Gerry

Hi guys

 

Reading through the VF Developer's Guide.  On page 85 there is this class defined as follows (it's a controller extension class)

 

public with sharing class AccountPagination {
private final Account acct;
// The constructor passes in the standard controller defined // in the markup below public AccountPagination(ApexPages.StandardSetController controller) { this.acct = (Account)controller.getRecord(); }
public ApexPages.StandardSetController accountRecords { get { if(accountRecords == null) { accountRecords = new ApexPages.StandardSetController( Database.getQueryLocator([SELECT Name FROM Account WHERE Id NOT IN (SELECT AccountId FROM Opportunity WHERE IsClosed = true)])); } return accountRecords; } private set; }
public List<Account> getAccountPagination() { return (List<Account>) accountRecords.getRecords(); } }

 Can someone please let me know what the constructor does?  

 

For a simple standard controller extension, the constructor looks like this:

 

public myControllerExtension(ApexPages.StandardController stdController) {
this.acct = (Account)stdController.getRecord();
}

 and I have no problem understanding that, you pass the controller to the extension class, and it always involves one record, so you get the record by calling the getRecord() method and cast it to an Account type.

 

However, when it is a standard set controller, I have problem understanding the purpose of calling the getRecord method (as opposed to the getRecords, the plural form).  SInce it is a standard set controller, I would think it returns a list of records. Because of that, the constructor like this,

public AccountPagination(ApexPages.StandardSetController controller) {
this.acct = (Account)controller.getRecord();
}

 

doesn't make sense to me.

 

I would've thought the constructor would look something more like this:

 

public AccountPagination(ApexPages.StandardSetController controller) {
List<Account> accounts = (List<Account>)controller.getRecords();
}

 

i.e. changng from singular to plural and changing the method from getRecord to getRecords.

 

So, my question is, what exactly does getRecord do, and why is the constructor the way it is (in the singular form, and not in the plural form)?

 

Thanks a lot

King