Forum Replies Created

  • Ratnakar

    Member
    April 10, 2018 at 2:22 pm in reply to: How to add error message in a Salesforce Apex Trigger?

    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.FATAL,'Enter Your error message here'));

  • Maximum Number of SOQL queries in a transaction: 100

    Maximum Number of query rows in a transaction: 50000

    Maximum Number of SOSL queries in a transaction: 20

  • Hi Pranav, Are you sure there is no way through which we can achieve above?

  • Hi kapil,

    you can use following code to get fields.

    SObjectType objectType = Schema.getGlobalDescribe().get('objectAPIName');
    Map<String,Schema.SObjectField> mfields = objectType.getDescribe().fields.getMap();

    mfields map have field names for that particular object which you will mention in objectAPIName.

    I hope this help you.

  • Ratnakar

    Member
    March 20, 2018 at 11:08 am in reply to: what is the difference between system mode and user mode?

    Hi,

    System Mode basically runs Apex code while ignoring the user’s permissions and privileges. In the System Mode, Apex code will have access to all the fields and objects while sharing rules and field security aren’t applied to the current user.

    All Apex code runs on System Mode and this ensures that the code won’t fail to run because of hidden objects for the user or hidden fields. The only exceptions here are anonymous blocks like standard controllers and developer consoles.

    In the User Mode, the code will be executed taking the privileges of the user into consideration. On the Salesforce platform, only Anonymous Apex and standard controllers can be executed in User Mode. In other words, it only runs Apex code by respecting the user’s permissions and sharing of records.

     

  • Hi,

    you can use following code:

    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Please enter value'));

    severity is a enum which can have following values:

    • CONFIRM
    • ERROR
    • FATAL
    • INFO
    • WARNING

    I hope this helps you.

  • Ratnakar

    Member
    March 15, 2018 at 4:37 pm in reply to: How to enable outbound message for a Salesforce org?

    Hi,

    To define outbound messages in a Salesforce Org, use this procedure in the Salesforce user interface:

    1. From Setup, enter Outbound Messages in the Quick Find box, then select Outbound Messages.
      Click New Outbound Message.
    2. Choose the object that has the information you want included in the outbound message, and click Next.
    3. Configure the outbound message.Enter a name and description for this outbound message.
    4. Enter an endpoint URL for the recipient of the message. Salesforce sends a SOAP message to this endpoint. For security reasons, Salesforce restricts the outbound ports you can specify to one of the following:

      80: This port only accepts HTTP connections.
      443: This port only accepts HTTPS connections.
      1024–66535 (inclusive): These ports accept HTTP or HTTPS connections.

    5. Select the Salesforce user to use when sending the message by specifying a username in the User to send as field. The chosen user controls data visibility for the message that is sent to the endpoint.
    6. Select Include Session ID if you want a sessionId to be included in the outbound message. Include the sessionId in your message if you intend to make API calls back to Salesforce from your listener.
    7. The sessionId represents the user defined in the previous step and not the user who triggered the workflow.
    8. Select the fields you want to be included in the outbound message and click Add.
    9. Click Save, and review the outbound message detail page.

    I hope these steps help you.

  • Ratnakar

    Member
    March 15, 2018 at 4:32 pm in reply to: What are the best practices followed when writing a test class?
    1. All test methods should reside in a separate class from the class in which the method being tested resides.
    2. Test classes should be appended with the word Test followed by the name of the class being tested, e.g. OpportunityServicesTest should be test class name if the controller class name is OpportunityServices.
    3. Should all use the @isTest annotation.
    4. Each method in the production class should have, at a minimum, one corresponding test method in its test class and should be appended by “test”
    5. There should be a minimum of “Null Pointer Exception test” as part of negative testing for each method, specially the methods that accept parameters.
    6. A method without an assert statement is not considered a test method. Large number of relevant assert statements increases confidence in the correct behavior of business logic.
    7. There should be a comment with each assert statement explaining what is being tested and what the expected output is.
    8. Only use isTest(SeeAllData = true) on class methods in exceptional cases where there are sObjects that doesn't allow DML operation e.g. PriceBook creation.
    9. No hard coded ids of any sObject in any test method.
    10. If a Constant needs to be asserted, its a best practice to reference that from the Constant class or from Custom Labels or Custom Settings. Using hard coded string in unit tests( or any class for that matter) will trigger failures when things like Picklist values change.
    11. All test data creation should be done from a Utility class. This allows for a streamlined creation of test objects that adhere to all the validation rules.
    12. Any business logic that needs to be tested should be enveloped within a Test.runAs(user) statement so profile restrictions can be tested. Using any admin profiles should be avoided.
    13. All private methods should also have its corresponding unit test method. In the production code, add a public method for each private method and prepend it by “exposeForUnitTest_”.
    14. Creating multiple test method for testing that same production code method should be avoided. We want to ensure that our unit test methods are properly testing the logic but the same time the efficiency of the unit test method should not be ignored. All the unit test methods run with every deployment so the cumulative run time should be as small as possible
    15. Any asynchronous method testing should include Test.startTest and Test.stopTest. Test.stopTest forces the asynchronous methods to run so the results could be asserted.
    16. Any exceptions that are caught in the production methods should be tested by feeding the test data that throws exception. Exception Type and error message should be asserted.
  • Ratnakar

    Member
    March 15, 2018 at 1:17 pm in reply to: What is the use of apex:facet in Salesforce Visualforce?

    Hi kapil,

    A placeholder for content that is rendered in a specific part of the parent component, such as the header or footer of an

    < apex:dataTable >.

    An < apex:facet > component can only exist in the body of a parent component if the parent supports facets. The name of the facet component must match one of the pre-defined facet names on the parent component. This name determines where the content of the facet component is rendered. Consequently, the order in which a facet component is defined within the body of a parent component does not affect the appearence of the parent component.

    Example:

    <apex:page standardController="Account">

    <apex:pageBlock title="Contacts">

    <apex:dataTable value="{!account.Contacts}" var="contact" cellPadding="4" border="1">

    <apex:column >

    <apex:facet name="header">Name</apex:facet>

    {!contact.Name}

    </apex:column>

    <apex:column >

    <apex:facet name="header">Phone</apex:facet>

    {!contact.Phone}

    </apex:column>

    </apex:dataTable>

    </apex:pageBlock>

    </apex:page>

  • Hi Kapil,

    Grant Account login access in salesforce is a powerful feature provide by salesforce. Sometimes you may have queries or issues with salesforce itself or the applications you have installed in your salesforce org. In order to assist you with the issue, you can grant account login access to the salesforce.com support or other Provider support whose applications you have installed in your org for a definite time.

    In this way support can login into your org, using your login and can fix the issues you are facing. This is a hassle free way, which avoids sharing your Salesforce Credentials.

  • Hi kapil,

    An external ID is a custom field that has the External ID attribute, meaning that it contains unique record identifiers from a system outside of Salesforce. External ID uniquely Identify a record outside of salesforce. We use external id when we are integrating salesforce with an external application.

  • Hi kapil,

    Once Quick text is enabled ,it can't be turned off.

    Screenshot from 2018-03-14 13-44-01

  • Hi Kapil,

    we cannot create objects using Apache ant but we can migrate objects from one salesforce org to another
    Following are the steps to migrate objects from one org to another:
    1.In the build.properties specify the username and password of the source and destination org.
    2.In the package.xml specify the name of object you want to retrieve.
    3.your build.properties look like this
    # build.properties
    #

    # Specify the login credentials for the desired Salesforce organization
    [email protected]
    sf.password=xxxxxxxxxxxxxxxxx

    [email protected]
    sf1.password=xxxxxxxxxxxxxxxxx
    #sf.sessionId = <Insert your Salesforce session id here. Use this or username/password above. Cannot use both>
    #sf.pkgName = <Insert comma separated package names to be retrieved>
    #sf.zipFile = <Insert path of the zipfile to be retrieved>
    #sf.metadataType = <Insert metadata type name for which listMetadata or bulkRetrieve operations are to be performed>

    # Use 'https://login.salesforce.com' for production or developer edition (the default if not specified).
    # Use 'https://test.salesforce.com for sandbox.
    sf.serverurl = https://login.salesforce.com
    sf1.serverurl = https://login.salesforce.com

    sf.maxPoll = 120
    sf1.maxPoll = 120
    # If your network requires an HTTP proxy, see http://ant.apache.org/manual/proxy.html for configuration.
    #

    4.your package.xml look like this

    <?xml version="1.0" encoding="UTF-8"?>
    <Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
    <members>specify the name of custom object</members>
    <name>CustomObject</name>
    </types>
    <version>40.0</version>
    </Package>
    5.command to retrieve object
    ant retrieveUnpackaged

    6.command to deploy object
    ant deployUnpackaged

  • Hi kapil,

    Workflow email alerts designed for Notifications to interested parties. It Runs When A case or lead is created or edited and Sends Email To Anyone you choose. It Sends one email per email alert. Each workflow rule can have up to:
    1) 10 email alerts as immediate actions.
    2) 10 email alerts per time trigger as time-dependent actions
    3) 10 time triggers

    where as Auto-response rules Designed For Initial response to the contact who created a case or the person who submitted the lead on the Web. It Runs when A case or lead is created and Sends Email To Contact on a case or the person who submitted the lead on the Web. Sends one email based on the first rule entry criteria it matches in a sequence of rule entries.

  • Ratnakar

    Member
    March 14, 2018 at 6:04 am in reply to: What is the difference between a Role and Profile in Salesforce?

    Hi kapil,

    Profiles control the objects, fields, tabs, apps page layout,record types available to the user.

    Role control record level access can be controlled by Role. Depending on your sharing settings, roles can control the level of visibility that users have into your organisation's data. Users at any given role level can view, edit, and report on all data owned by or shared with users below them in the hierarchy, unless your organisation's sharing model for an object specifies otherwise.