Forum Replies Created

Page 16 of 16
  • MOHIT

    Member
    January 23, 2020 at 1:50 pm in reply to: Which fields are automatically indexed in Salesforce?

    These are the fields that are automatically indexed in Salesforce :

    Name

    Email (for contacts and leads)

    Division

    CreatedDate

    Systemmodstamp (LastModifiedDate)

    Foreign key relationships (lookups and master-detail)

    RecordTypeId

  • MOHIT

    Member
    January 23, 2020 at 1:37 pm in reply to: Why are Visualforce pages served from a different domain?

    All our Visualforce pages are used like “c.YOURSERVER.visual.force.com/apex/YOURPAGENAME” ,
    And because of this most of time we run into Same-Origin Policy error in Javascripyt if we try to access parent page from different domain.

  • MOHIT

    Member
    January 22, 2020 at 5:37 pm in reply to: Output panel vs Pageblock section in Salesforce

    <apex:pageblocksection> tag is used in visualforce page to create sub section inside a page block. To limit the number of fields values to display in pageblockSection we use attribute called column While Output panel tag is used to Conditionally render a section of block of html element using  its render attributes .

  • MOHIT

    Member
    January 22, 2020 at 5:22 pm in reply to: dataTable tag vs pageBlockTable in Visualforce

    <Apex:datatable> tag is used to create data tables in visualforce pages. Each item in the data table is displayed in the form of rows and columns while, <apex:pageblock> is  used to create a section of Block in visualforce page. We can create multiple input fields, buttons, tables, links in page block section. In page block section we can create page block sections.

  • 10  is the maximum limit of field dependencies we can use in the VisualForce page in Salesforce.

  • Yes, we can create both master detail relationship and Look-Up Relationship on single object in salesforce at a time. We can also change master detail relationship to Look-Up Relationship or vice versa.

  • MOHIT

    Member
    January 21, 2020 at 5:54 pm in reply to: What is a Wrapper Class in Salesforce?

    Wrapper Class in Apex Salesforce : It is a class, a data structure, or an abstract data type which contains different objects or collection of objects as its members. It is also known as container class

    A wrapper class is a custom object defined by programmer in which he defines the wrapper class properties.  Wrapper class is a custom class which has different data types or properties as per requirement. We can wrap different objects types or any other types in a wrapper class.

  • MOHIT

    Member
    January 21, 2020 at 5:46 pm in reply to: What are the limitations of validation rule in Salesforce?

    In Salesforce Unlimited Edition we can have 500 Active validations rule and In developer Org we  have 100 Active validation rules.

    I have attached a document for Salesforce_app_limitation  the limitations of validation rule in Salesforce

  • MOHIT

    Member
    January 20, 2020 at 7:58 pm in reply to: What is generic sObject means in Salesforce?

    Every record in Salesforce is natively represented as an sObject in Apex.

    Each Salesforce record is represented as an sObject before it is inserted into Salesforce. Likewise, when persisted records are retrieved from Salesforce, they’re stored in an sObject variable.

    Standard and custom object records in Salesforce map to their sObject types in Apex. Here are some common sObject type names in Apex used for standard objects.

    Account
    Contact
    Lead
    Opportunity
    If you’ve added custom objects in your organization, use the API names of the custom objects in Apex.

  • global void execute(SchedulableContext cc) {
    BatchApexClass batchObject = new BatchApexClass();
    Database.executeBatch(batchObject,10) ;// I think you are asking about this 10.}

    Basically, Database's executeBatch method has two overloads

    One which takes only one parameter i.e. instance of the batch class and does not take scope as parameter and processes the records with default batch size of 200.
    Other which takes two parameters, first the instance of the batch class and second the scope variable i.e. an integer which specifies the number of records to be passed into the execute method for batch processing.
    So in above example, its the second overload which will pass 10 records at a time to execute method of batch class for processing. If you have 100 records in all to be processed and if you have set your batch size as 10, your records would be split in 100/10 i.e. 10 batches i.e. execute method will run 10 times.

    The default size of the scope if not specified is 200 and the maximum value it can have is 2000.

    Excerpt from Salesforce Database class documentation

    The value for scope must be greater than 0.

    If the start method of the batch class returns a Database.QueryLocator, the scope parameter of Database.executeBatch can have a maximum value of 2,000. If set to a higher value, Salesforce chunks the records returned by the QueryLocator into smaller batches of up to 200 records. If the start method of the batch class returns an iterable, the scope parameter value has no upper limit; however, if you use a very high number, you could run into other limits.

    Apex governor limits are reset for each execution of execute.

  • MOHIT

    Member
    January 20, 2020 at 7:47 pm in reply to: What is aggregate Query in Apex?

    Aggregate functions in salesforce include AVG(), COUNT(), MIN(), MAX(), SUM().The functions like  SUM() and MAX() in SOQL allow to roll up and summarize the data in a query. The GROUP BY clause in a SOQL query is to avoid iterating through individual query results and used to specify a group of records instead of processing many individual records.

    AVG() – Returns the average value of a numeric field
    COUNT() – Returns the number of rows matching the query criteria
    MIN() – Returns the minimum value of a field
    MAX() – Returns the maximum value of a field
    SUM() – Returns the total sum of a numeric field
    A query that includes an aggregate function returns its results in an array of AggregateResult objects. AggregateResult is a read-only sObject and is only used for query results. The values in the AggregateResult object can be accessed much like a map calling a “get” method with the name of the column.

  • MOHIT

    Member
    January 17, 2020 at 2:57 pm in reply to: could anyone explain in detail \"List<List<sObject>>" in Salesforce?

    List<List<sObject>> --> a list of a list of objects?

    What does that mean and where is that used?
    it means you have a list of a list of objects such as a list of account list, contact list, opportunity list

    it is use main in SOSL, or also known as global search.  For example when doing a global search on "johnson"

    You get a list of accounts, list of contacts, list of opportunities etc match the criteria

    String searchQuery = 'FIND '' + searchStr1 + '' IN ALL FIELDS RETURNING  Account (Id,Name,type),Contact(name,email),Opportunity(name,StageName)';   List<List <sObject>> searchList = search.query(searchQuery);
    accList = ((List<Account>)searchList[0]);
    conList = ((List<contact>)searchList[1]);
    optyList = ((List<Opportunity>)searchList[2]);

    The example above has List<List<sObject>> of accounts, contacts, and opportunities using the FIND search in SOSL.

  • trigger ContactTrigger on Contact (after insert, after update, after delete, after undelete) {
    //---> above handling all states which could see a contact added to or removed from an account

    //---> on delete we use Trigger.Old, all else, Trigger.new
    List<Contact> contacts = Trigger.isDelete ? Trigger.old : Trigger.new;

    //---> the Set class rocks for finding the unique values in a list
    Set<Id> acctIds = new Set<Id>();

    for (Contact c : contacts) {
    //yes, you can have a contact without an account
    if (c.AccountId != null) {
    acctIds.add(c.AccountId);
    }
    }

    List<Account> acctsToRollup = new List<Account>();

    //****** Here is the Aggregate query...don't count in loops, let the DB do it for you*****
    for (AggregateResult ar : [SELECT AccountId AcctId, Count(id) ContactCount
    FROM Contact
    WHERE AccountId in: acctIds
    GROUP BY AccountId]){
    Account a = new Account();
    a.Id = (Id) ar.get('AcctId'); //---> handy trick for updates, set the id and update
    a.Contact_Count__c = (Integer) ar.get('ContactCount');
    acctsToRollup.add(a);
    }

    //----> probably you'll want to do a little more error handling than this...but this should work.
    update acctsToRollup;

    }

Page 16 of 16