Forum Replies Created

Page 8 of 8
  • Aman

    Member
    July 17, 2017 at 6:42 am in reply to: Why future method is void and static in Salesforce?

    Hello Shubham,

    Future methods will run in the future. You don't want your synchronous code waiting an unknown period of time for an asynchronous bit of code to finish working.

    The whole point is you want to clearly separate what happens now from what happens in the future.

    By only returning void, you can't have code that waits for a result.

    Future method by definition is static so that variables with this method is associated to the class and not the instance and you can access them without instantiating the class.

     

  • Aman

    Member
    July 13, 2017 at 2:29 pm in reply to: What is the working of Map in Salesforce?

    Hello Shariq,

    A map is a collection of key-value pairs where each unique key maps to a single value. Keys and values can be any data type—primitive types, collections, sObjects, user-defined types, and built-in Apex types.

    To declare a map, use the Map keyword followed by the data types of the key and the value within <> characters. For example:

    Map<String, String> country_currencies = new Map<String, String>();

    Map<ID, Set<String>> m = new Map<ID, Set<String>>();

  • Aman

    Member
    July 13, 2017 at 1:39 pm in reply to: What is the governor limits of sub query in SOQL?

    Hello Saloni,

    In a SOQL query with parent-child relationship subqueries, each parent-child relationship counts as an extra query. These types of queries have a governor limit of three times the number for top-level queries. The row counts from these relationship queries contribute to the row counts of the overall code execution.

    • This reply was modified 6 years, 9 months ago by  Aman.
  • Aman

    Member
    July 13, 2017 at 12:20 pm in reply to: How can we count number of contacts associated with accounts?

    Hello Saloni,

    List<Account> acc=[select Name , (Select LastName from contacts) from Account Limit 10];
    for(Account acct:acc){
    system.debug('####'+acct.contacts.size());
    }

     

  • Aman

    Member
    July 12, 2017 at 12:16 pm in reply to: Where we use application custom event in Salesforce?

    Hello Shubham,

    Application Events:

    Application events follow a traditional publish-subscribe model. An application event is fired from an instance of a component. All components that provide a handler for the event are notified.

     

    Component Events:

    A component event is fired from an instance of a component. A component event can be handled by the component that fired the event or by a component in the containment hierarchy that receives the event.

  • Aman

    Member
    July 12, 2017 at 11:53 am in reply to: Salesforce - What is Macros in Automate Case Management?

    A macro is a set of instructions, which tell the system how to complete a task. When an agent runs a macro, the system performs each instruction. Macros save time and add consistency to support agents’ work.Support agents who use Case Feed now can run macros to automatically complete repetitive tasks—such as selecting an email template, sending an email to a customer, and updating the case status—all in a single click.

    Available in: Salesforce Classic
    Available in: Professional, Enterprise, Performance, Unlimited, and Developer Editions

    You can create macros to perform multiple actions on the Case Feed. For example, a macro can enter the subject line of an email and update the case status. A single macro can perform multiple actions on different parts of the Case Feed at the same time.

     

  • Aman

    Member
    July 11, 2017 at 3:57 pm in reply to: Can we fire events on key press in Lightning for Salesforce?

    Hello shariq,

    UI components provide easy handling of user interface events such as keyboard and mouse interactions. By listening to these events, you can also bind values on UI input components using the updateon attribute, such that the values update when those events are fired.
    Capture a UI event by defining its handler on the component.

  • Hello Shariq,

    Application Event:

    Application event follows a traditional publish-subscribe model. An application event is fired from an instance of a component. All components that provide a handler for the event are notified.

    Component Event:

    A component event is fired from an instance of a component. A component event can be handled by the component that fired the event or by a component in the containment hierarchy that receives the event.

  • Aman

    Member
    July 11, 2017 at 3:34 pm in reply to: How OOPS concept is different in apex from java

    Apex classes and Java classes work in similar ways, but there are some significant differences.
    These are the major differences between Apex classes and Java classes:
    Inner classes and interfaces can only be declared one level deep inside an outer class.
    Static methods and variables can only be declared in a top-level class definition, not in an inner class.
    An inner class behaves like a static Java inner class, but doesn’t require the static keyword. An inner class can have instance member variables like an outer class, but there is no implicit pointer to an instance of the outer class (using the this keyword).
    The private access modifier is the default, and means that the method or variable is accessible only within the Apex class in which it is defined. If you do not specify an access modifier, the method or variable is private.
    Specifying no access modifier for a method or variable and the private access modifier are synonymous.
    The public access modifier means the method or variable can be used by any Apex in this application or namespace.
    The global access modifier means the method or variable can be used by any Apex code that has access to the class, not just the Apex code in the same application. This access modifier should be used for any method that needs to be referenced outside of the application, either in the SOAP API or by other Apex code. If you declare a method or variable as global, you must also declare the class that contains it as global.
    Methods and classes are final by default.
    The virtual definition modifier allows extension and overrides.
    The override keyword must be used explicitly on methods that override base class methods.
    Interface methods have no modifiers—they are always global.
    Exception classes must extend either exception or another user-defined exception.
    Their names must end with the word exception.
    Exception classes have four implicit constructors that are built-in, although you can add others.
    Classes and interfaces can be defined in triggers and anonymous blocks, but only as local.

  • Aman

    Member
    July 11, 2017 at 2:57 pm in reply to: what is the use of Database.Stateful in Salesforce Batch Class?

    Each execution of a batch Apex job is considered a discrete transaction. For example, a batch Apex job that contains 1,000 records and is executed without the optional scope parameter is considered five transactions of 200 records each.

    If you specify Database.Stateful in the class definition, you can maintain state across these transactions. When using Database.Stateful, only instance member variables retain their values between transactions. Static member variables don’t retain their values and are reset between transactions. Maintaining state is useful for counting or summarizing records as they’re processed. For example, suppose your job processed opportunity records. You could define a method in execute to aggregate totals of the opportunity amounts as they were processed.

    If you don’t specify Database.Stateful, all static and instance member variables are set back to their original values.

    The following example summarizes a custom field total__c as the records are processed.

    global class SummarizeAccountTotal implements Database.Batchable<sObject>, Database.Stateful{
        global final String Query;
        global integer Summary;
        global SummarizeAccountTotal(String q){
            Query=q;
            Summary = 0;
        }
        global Database.QueryLocator start(Database.BatchableContext BC){
            return Database.getQueryLocator(query);
        }
        global void execute (
            Database.BatchableContext BC,
            List<sObject> scope){
                for(sObject s : scope){
                    Summary = Integer.valueOf(s.get(‘total__c’))+Summary;
                }
            }
        global void finish(Database.BatchableContext BC){
        }
    }
  • Aman

    Member
    July 11, 2017 at 2:23 pm in reply to: Use of Database.Insert in SOQL?

    Hello Saloni ,

    One difference between the two options is that by using the Database class method, you can specify whether or not to allow for partial record processing if errors are encountered.The syntax of Database.insert is Database.insert(acctList, Parameter).The default value for this parameter is true,which means that if at least one sObject can’t be processed, all remaining sObjects won’t and an exception will be thrown for the record that causes a failure.If you specify false for this parameter and if a record fails, the remainder of DML operations can still succeed. Also, instead of exceptions, a result object array (or one result object if only one sObject was passed in) is returned containing the status of each operation and any errors encountered.

    List<Account> acctList = new List<Account>();
    acctList.add(new Account(Name='Acme1'));
    acctList.add(new Account(Name='Acme2'));
    // DML statement
    Database.SaveResult[] srList = Database.insert(acctList, false);
    // Iterate through each returned result

    for (Database.SaveResult sr : srList) {
    if (sr.isSuccess()) {
    // Operation was successful, so get the ID of the record that was processed
    System.debug('Successfully inserted account. Account ID: ' + sr.getId());
    }
    else {
    // Operation failed, so get all errors
    for(Database.Error err : sr.getErrors()) {
    System.debug('The following error has occurred.');
    System.debug(err.getStatusCode() + ': ' + err.getMessage());
    System.debug('Account fields that affected this error: ' + err.getFields());
    }
    }
    }

  • Hello Saloni,

    Sometimes we create a local Method with the name deserialize  which has different functionality than deserialize method provided by Salesforce. Salesforce always give priority to local methods ,if we call  JSON.deserialize it will provide the functionality in local method and by calling  System.JSON.deserialize it will provide the functionality in standard deserialize method.

  • Aman

    Member
    July 5, 2017 at 1:48 pm in reply to: Merge Custom Object Records in Salesforce

    Hello Mohsin,

    You can try some app from appExchange because this feature is not available by default in salesforce.

  • Aman

    Member
    July 5, 2017 at 1:16 pm in reply to: What are different Salesforce annotations?

    An Apex annotation modifies the way that a method or class is used, similar to annotations in Java. Annotations are defined with an initial @ symbol, followed by the appropriate keyword.
    To add an annotation to a method, specify it immediately before the method or class definition.

    Apex supports the following annotations.

    @AuraEnabled
    @Deprecated
    @Future
    @InvocableMethod
    @InvocableVariable
    @IsTest
    @ReadOnly
    @RemoteAction
    @TestSetup
    @TestVisible

    Apex REST annotations:

    @RestResource(urlMapping='/yourUrl')
    @HttpDelete
    @HttpGet
    @HttpPatch
    @HttpPost
    @HttpPut

Page 8 of 8