Forum Replies Created

Page 4 of 5
  • shradha jain

    Member
    August 7, 2018 at 6:32 am in reply to: Explain use of Junction Object in Salesforce.

    Hello Madhulika,

    Junction Object is a custom object with two master-detail relationships. Using a custom junction object, you can model a “many-to-many” relationship between two objects. For example, you create a custom object called “Bug” that relates to the standard case object such that a bug could be related to multiple cases and a case could also be related to multiple bugs.

    Creating the many-to-many relationship consists of:

    1. Creating the junction object.
    2. Creating the two master-detail relationships.
    3. Customizing the related lists on the page layouts of the two master objects.
    4. Customizing reports to maximize the effectiveness of the many-to-many relationship.

    You can refer the following link :

    https://help.salesforce.com/articleView?id=relationships_manytomany.htm&type=5

    Thanks.

  • Hello Prachi,

    Bound Expression: Bound Expression is represented as {!v.messageText}. Whenever the value of the string is changed, this expression will reflect the change and also affect the components where it is used, we can say the value change dynamically through this expression.

    Unbound Expression: Unbound Expression is represented as {#v.messageText}. Whenever the value of the string is changed, this expression will not reflect the change, we can say the value remains static through this expression.

    Example :

    <aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
    <aura:attribute name="str" type="string" default="Hello World!"/>
    <ui:outputText value="Enter a string value : "/><ui:inputText value="{!v.str}"/>
    <br/><br/>
    <ui:outputText value="{#v.str}"/>
    <br/><br/>
    <ui:outputText value="{!v.str}"/>
    </aura:component>

    Thanks.

  • shradha jain

    Member
    August 7, 2018 at 5:10 am in reply to: What is the order of execution in Salesforce Triggers?

    Hello Anjali,

    When you save a record with an insert, update, or upsert statement.

    Salesforce performs the following events in order:
    1. On the server, Salesforce:Loads the original record from the database or initializes the record for an upsert statement.
    2. Loads the new record field values from the request and overwrites the old values.If the request came from a standard UI edit page, Salesforce runs system validation to check the record for:

    • Compliance with layout-specific rules
    • Required values at the layout level and field-definition level
    • Valid field formats
    • Maximum field length
      When the request comes from other sources, such as an Apex application or a SOAP API call, Salesforce validates only the foreign keys. Before executing a trigger, Salesforce verifies that any custom foreign keys do not refer to the object itself.Salesforce runs user-defined validation rules if multiline items were created, such as quote line items and opportunity line items.

    3.Executes all before triggers.
    4. Runs most system validation steps again, such as verifying that all required fields have a non-null value, and runs any user-defined validation rules. The only system validation that Salesforce doesn't run a second time (when the request comes from a standard UI edit page) is the enforcement of layout-specific rules.
    5. Executes duplicate rules. If the duplicate rule identifies the record as a duplicate and uses the block action, the record is not saved and no further steps, such as after triggers and workflow rules, are taken.
    6. Saves the record to the database, but doesn't commit yet.
    7. Executes all after triggers.
    8. Executes assignment rules.
    9. Executes auto-response rules.
    10. Executes workflow rules.
    11. If there are workflow field updates, updates the record again.
    12. If the record was updated with workflow field updates, fires before update triggers and after update triggers one more time (and only one more time), in addition to standard validations. Custom validation rules, duplicate rules, and escalation rules are not run again.
    13. Executes processes and flows launched via processes and flow trigger workflow actions.When a process or flow executes a DML operation, the affected record goes through the save procedure.
    14. Executes escalation rules.
    15. Executes entitlement rules.
    16. If the record contains a roll-up summary field or is part of a cross-object workflow, performs calculations and updates the roll-up summary field in the parent record. Parent record goes through save procedure.
    17. If the parent record is updated, and a grandparent record contains a roll-up summary field or is part of a cross-object workflow, performs calculations and updates the roll-up summary field in the grandparent record. Grandparent record goes through save procedure.
    18.Executes Criteria Based Sharing evaluation.
    19. Commits all DML operations to the database.
    20. Executes post-commit logic, such as sending email.

    Thanks.

  • shradha jain

    Member
    August 6, 2018 at 8:47 am in reply to: Can we use DML operation in Salesforce Apex Constructor?

    Hello chanchal,

    No, you can't perform any DML in Constructor because using DML in constructor will slow down initialization of your object and using insert/update/delete in constructor is a bad practice in any language.
    A quick solution would be to place the dml operations in a single method that you call from the page action parameter.

    Here is the VF page:

    <apex:page controller="pageController" action="{!doSomeDMLStuff}">
    APEX Class:

    public pageController{

    private boolean doDML;

    //constructor
    public pageController(){

    //run some logic to decide if you need to execute dml statements

    if(logic = true){

    doDML= true;
    }

    //the method called from the page action

    public pagereference doSomeDMLStuff(){

    if(doDML){
    //run DML statements

    }
    return null;
    }

    }
    }

    Thanks.

  • Hello anurag,

    No,it is not necessary to use apex tags while constructing visualforce page.You can use HTML tags instead but it is compulsory to use <apex:page>tag.You can write HTML inside <apex:page>tag.You can refer the following example:

    <apex:page showHeader="false" standardStylesheets="false" sidebar="false">
    <html>
    <head>
    <title>Test</title>
    </head>
    <body>
    <p>This is a test.</p>
    </body>
    </html>
    </apex:page>

  • Hello Chanchal,

    You can refer to the following example to  define a custom type for both acccount and contact object using wrapper class:

    public with sharing class conacc {

    public List<MyWrapper> wrapper {get; set;}

    public List<Account> accLst1 {get; set;
    public List<Contact> conLst1 {get; set;}

    public conacc ()

    {
    accLst1 = [select id,Name from Account ] ;
    conLst1 = [select Id,Name from contact where AccountId IN : accLst1 ] ;
    wrapper = new List<MyWrapper>() ;
    for(Integer i=0 ; i < 20; i++)
    wrapper.add(new MyWrapper( conLst1, accLst1[i])) ;
    System.debug('----------'+ wrapper);
    }
    public class MyWrapper
    {
    public Account accRec1 {get; set;}
    public List<Contact> conRec1 {get; set;}
    public MyWrapper( List<Contact> con ,Account acc )
    {
    accRec1 = acc ;
    conRec1 = con ;
    }

    }

    }

  • shradha jain

    Member
    August 6, 2018 at 6:52 am in reply to: What is the use of writing sharing rules in Salesforce?

    Hello Sanjana,

    You can use sharing rules to extend sharing access to users in public groups or roles. As with role hierarchies, sharing rules can never be stricter than your org-wide default settings. Sharing rules just allow greater access for particular users.If you have org-wide sharing defaults of Public Read Only or Private, you can open access back up for some users with sharing rules. This enables you to make automatic exceptions to your org-wide sharing settings for selected sets of users.

    Thanks.

  • shradha jain

    Member
    August 6, 2018 at 6:21 am in reply to: Can we edit a scheduled job in Salesforce Apex?

    Hello Sanjana,
    You cannot update the scheduled jobs. You need to delete the existing job and then schedule it again.

  • Hello Prachi,

    TestVisible annotation allows test methods to access private or protected members of another class outside the test class. These members include methods, member variables, and inner classes.

    With this annotation, you don’t have to change the access modifiers of your methods and member variables to public if you want to access them in a test method. For example, if a private member variable isn’t supposed to be exposed to external classes but it should be accessible by a test method, you can add the TestVisible annotation to the variable definition.

    Thanks.

  • Hello Anurag,

    A callout in Future Apex method is a callout to external Web services. If you are making callouts from a trigger or after performing a DML operation, you must use a future or queueable method.

    Thanks.

  • shradha jain

    Member
    August 3, 2018 at 5:01 am in reply to: What is the return type of Future Method in Salesforce?

    Hello Sanjana,

    The return type of Future Method can only be a void type.

    Thanks.

  • shradha jain

    Member
    August 3, 2018 at 4:57 am in reply to: How to handle error records in Salesforce Batch apex?

    Hello Prachi,

    First of all you need to make your batch class stateful using Database.Stateful .

    public class SimpleBatch implements Database.Batchable<sObject>,Database.Stateful{
    A global variable required which will maintained failed record.

    global List<String> exception_List;
    Use Database.update method instead of update with allOrNothing = false parameter which will return how many records has passed and failed in update call.

    Database.SaveResult[] SaveResultList = Database.update(objsToUpdate,false);
    You will iterate saveResultList and you will add failed records in exception_list

    for(integer i =0; i<objsToUpdate.size();i++){
    String msg='';
    If(!SaveResultList[i].isSuccess()){
    msg += userList.get(i).id + '\n'+'Error: "';
    for(Database.Error err: SaveResultList[i].getErrors()){
    msg += err.getmessage()+'"\n\n';
    }
    }
    if(msg!='')
    exception_List.add(msg);
    }
    You can use this exception_list in execute method to send in your final email.

    Thanks.

  • shradha jain

    Member
    July 31, 2018 at 1:30 pm in reply to: What are the Salesforce annotations? List all of them.

    Hello Madhulika,

    Apex annotations modify the way a method or class is used. Below is the list of annotations supported by Salesforce:

    @Deprecated:
    Use the deprecated annotation to identify methods, classes, exceptions, enums, interfaces, or variables that can no longer be referenced in subsequent releases of the managed package in which they reside. This is useful when you are refactoring code in managed packages as the requirements evolve. New subscribers cannot see the deprecated elements, while the elements continue to function for existing subscribers and API integrations.

    @Future:
    Use the future annotation to identify methods that are executed asynchronously. When you specify future, the method executes when Salesforce has available resources.
    To test methods defined with the future annotation, call the class containing the method in a startTest, stopTest code block. All asynchronous calls made after the startTest method are collected by the system. When stopTest is executed, all asynchronous processes are run synchronously.

    @IsTest:
    Use the isTest annotation to define classes or individual methods that only contain code used for testing your application. The isTest annotation is similar to creating methods declared as testMethod.

    @ReadOnly:
    The @ReadOnly annotation allows you to perform unrestricted queries against the Force.com database. All other limits still apply. It's important to note that this annotation, while removing the limit of the number of returned rows for a request, blocks you from performing the following operations within the request: DML operations, calls to System.schedule, calls to methods annotated with @future, and sending emails.

    @RemoteAction:
    The RemoteAction annotation provides support for Apex methods used in Visualforce to be called via JavaScript. This process is often referred to as JavaScript remoting.

    @TestVisible:
    Use the TestVisible annotation to allow test methods to access private or protected members of another class outside the test class. These members include methods, member variables, and inner classes. This annotation enables a more permissive access level for running tests only.

    Apex REST annotations:

    @RestResource(urlMapping='/yourUrl'):
    The @RestResource annotation is used at the class level and enables you to expose an Apex class as a REST resource.

    @HttpDelete:
    The @HttpDelete annotation is used at the method level and enables you to expose an Apex method as a REST resource. This method is called when an HTTP DELETE request is sent and deletes the specified resource.

    @HttpGet:
    The @HttpGet annotation is used at the method level and enables you to expose an Apex method as a REST resource. This method is called when an HTTP GET request is sent and returns the specified resource.

    @HttpPatch:
    The @HttpPatch annotation is used at the method level and enables you to expose an Apex method as a REST resource. This method is called when an HTTP PATCH request is sent and updates the specified resource.

    @HttpPost:
    The @HttpPost annotation is used at the method level and enables you to expose an Apex method as a REST resource. This method is called when an HTTP POST request is sent and creates a new resource.

    @HttpPut:
    The @HttpPut annotation is used at the method level and enables you to expose an Apex method as a REST resource. This method is called when an HTTP PUT request is sent and creates or updates the specified resource.

  • shradha jain

    Member
    July 31, 2018 at 6:23 am in reply to: How are Salesforce records queued for Indexing?

    Hello Madhulika,

    As the records are created ,they are queued for indexing on the order of request(ie.,First Come First Serve).The indexes are created using the search indexing servers, which also generate and asynchronously process queue entries of newly created or modified data.

    • This reply was modified 6 years, 3 months ago by  shradha jain.
  • Hello Sanjana,

    The different types of collections in Apex are:

    1. Lists: A list is an ordered collection of elements that are distinguished by their indices. List elements can be of any data type—primitive types, collections, sObjects, user-defined types, and built-in Apex types.
    2. Sets: A set is an unordered collection of elements that do not contain any duplicates. Set elements can be of any data type—primitive types, collections, sObjects, user-defined types, and built-in Apex types.
    3. Maps: 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.
  • Hello Madhulika,

    CronTrigger is object that contains schedule information for a scheduled job.The SchedulableContext getTriggerID method returns the ID of the CronTrigger object associated with this scheduled job as a string. You can query CronTrigger to track the progress of the scheduled job.

  • Hello Chanchal,

    Synchronous:

    If an API call is synchronous, it means that code execution will block (or wait) for the API call to return before continuing. This means that until a response is returned by the API, your application will not execute any further, which could be perceived by the user as latency or performance lag in your app. Making an API call synchronously can be beneficial, however, if there if code in your app that will only execute properly once the API response is received.
    Asynchronous:

    Asynchronous calls do not block (or wait) for the API call to return from the server. Execution continues on in your program, and when the call returns from the server, a "callback" function is executed.

  • No, the method trigger:old is not only used for the event “before delete”.It can be used for both update and delete triggers.

  • Hello Sanjana,

    Trigger.old: Returns a list of the old versions of the sObject records. Trigger.old should return a type ofList<sObject__c>.Note that this sObject list is only available in the update and delete triggers.

    Trigger.oldMap: A map of IDs to the old versions of the sObject records. Trigger.oldMap should return a type of Map<Id, sObject__c>.Note that this map is only available in the update and delete triggers.

  • Hello Chanchal,

    In Salesforce we can create four types of report formats:

    1. Tabular Reports: Simple listing of data without any subtotals. This type of reports provide you most basically to look your data. Use tabular reports when you want a simple list or a list of items with a grand total.

    2. Summary Reports: This type of reports provide a listing of data with groupings and sub totals. Use summary reports when you want subtotals based on the value of a particular field or when you want to create a hierarchically grouped report, such as sales organized by year and then by quarter.

    3. Matrix Reports: This type of reports allow you to group records both by row and by column. A comparison of related totals, with totals by both row and column. Use matrix reports when you want to see data by two different dimensions that aren’t related, such as date and product.

    4. Joined Reports: Blocks of related information in a single report. This type of reports enable you to adopt five different blocks to display different types of related data. Each block can own unique columns, summary fields, formulas, filters and sort order. Use joined reports to group and show data from multiple report types in different views.

     

  • shradha jain

    Member
    July 30, 2018 at 6:28 am in reply to: What is fault element in SOAP message in Salesforce?

    Hello Chanchal,

    When a Web service request is being processed, if an error is encountered, the nature of the error needs to be communicated to the client, or sender of the request. Because clients can be written on a variety of platforms using different languages, there must exist a standard, platform-independent mechanism for communicating the error.

    The SOAP specification defines a standard, platform-independent way of describing the error within the SOAP message using a SOAP fault. In general, a SOAP fault is analogous to an application exception. SOAP faults are generated by receivers to report business logic errors or unexpected conditions.

    The faults are returned to the sender only if request/response messaging is in use. If a Web service operation is configured as one-way, the SOAP fault is not returned to the sender, but stored for further processing.

    The SOAP <Fault> element is used to transmit error and status information within a SOAP message. The <Fault> element is a child of the body element. There can be only one <Fault> element in the body of a SOAP message.

    Subelements of the SOAP 1.2 <Fault> Element are:

    • env:Code - Information pertaining to the fault error code.
    • env:Value - Code value that provides more information about the fault.
    • env:Subcode - Subcode value that provides more information about the fault. This subelement can have a recursive structure.
    • env:Reason - Human-readable description of fault.
    • env:node - Information regarding the actor (SOAP node) that caused the fault
    • env:Role - Role being performed by actor at the time of the fault.
    • env:Detail - Application-specific information, such as the exception that was thrown.
  • shradha jain

    Member
    July 30, 2018 at 6:19 am in reply to: Lightning in salesforce

    Hello Madhulika,

    The @AuraEnabled annotation enables client- and server-side access to an Apex controller method. Providing this annotation makes your methods available to your Lightning components. Only methods with this annotation are exposed.

  • We can use Lightning Component to customize and extend Lightning Experience and the Salesforce app with Lightning components. We can launch components from tabs, apps, and actions.

    Configure Components for Custom Tabs:
    Add the force:appHostable interface to a Lightning component to allow it to be used as a custom tab in Lightning Experience or the Salesforce mobile app.

    Add Lightning Components as Custom Tabs in a Lightning Experience App:
    Make your Lightning components available for Lightning Experience users by displaying them in a custom tab in a Lightning Experience app.

    Add Lightning Components as Custom Tabs in the Salesforce App:
    Make your Lightning components available for Salesforce for Android, Salesforce for iOS, and Salesforce mobile web users by displaying them in a custom tab.

    Lightning Component Actions:
    Lightning component actions are custom actions that invoke a Lightning component. They support Apex and JavaScript and provide a secure way to build client-side custom functionality. Lightning component actions are supported only in the Salesforce mobile app and Lightning Experience.

    Override Standard Actions with Lightning Components:
    Add the lightning:actionOverride interface to a Lightning component to enable the component to be used to override a standard action on an object. You can override the View, New, Edit, and Tab standard actions on most standard and all custom components. Overriding standard actions allows you to customize your org using Lightning components, including completely customizing the way you view, create, and edit records.

  • Post Install Script :

    A post install script is an Apex class that implements the InstallHandler interface. This interface has a single method called onInstall that specifies the actions to be performed on installation.

    global interface InstallHandler {
    void onInstall(InstallContext context)
    }

    The onInstall method takes a context object as its argument, which provides the following information:
    1.The org ID of the organization in which the installation takes place.
    2. The user ID of the user who initiated the installation.
    3. The version number of the previously installed package (specified using the Version class). This is always a three-part number, such as 1.2.0.
    4. Whether the installation is an upgrade.
    5. Whether the installation is a push.

    Post Uninstall Script:

    An uninstall script is an Apex class that implements the UninstallHandler interface. This interface has a single method called onUninstall that specifies the actions to be performed on uninstall.

    global interface UninstallHandler {
    void onUninstall(UninstallContext context)
    }

    The onUninstall method takes a context object as its argument, which provides the following information:
    1. The org ID of the organization in which the uninstall takes place.
    2. The user ID of the user who initiated the uninstall.

  • shradha jain

    Member
    July 27, 2018 at 9:56 am in reply to: Which operations can we perform on Dataloader in Salesforce?

    Hello Madhulika,

    Operations that can  be performed on dataloader are:

    1. Insert: Inserting brand new records
    2. Update: Updating the existing records based on the record ID
    3. Upsert: To Upsert we should have one external ID field on the object, based on the external id field if the value already exists it will update, if doesn't exist then it will insert
    4. Delete: Delete the records based on the id provided, to delete we need only id, deleted records can be found in recycle bin.
    5. Hard delete: Delete the records based on the id provided, to delete we need only id, deleted records can't be found in recycle bin.
    6. Export: From any object we can export records based on the SOQL query, Note: We can't export deleted records which are there in the recycle bin.
    7. Export all: From any object we can export records based on the SOQL query, Note: Using Export all we can export deleted records which are there in the recycle bin also.
Page 4 of 5