Forum Replies Created

Page 41 of 53
  • Parul

    Member
    September 16, 2018 at 12:27 pm in reply to: What is Database.rollback in Salesforce?

    database.savepoint is a method which is used to define a point which can be roll back to. If any error occurs during a transaction, that contains many statements, the application will roll back to the most recent savepoint and the entire transaction will not be aborted.

    for example,

    Account acc = new Account();
    acc.name ='ABC';
    ----                      --------
    ----- some code ---------
    Savepoint sp = Database.setSavepoint();
    try{
    insert acc;
    }
    catch( Exception e ){
    Database.rollback( sp );
    }
    ------ the code continues -----

    In this exapmle, if any error occurs while inserting the acc then the entire transaction will rollbak to savepoint sp ( as specified in the catch section by Database.rollback method).

     

    Thanks

  • Parul

    Member
    September 16, 2018 at 12:25 pm in reply to: What is the difference Web-to-Case and Email-to-Case?

    Email-to-Case
    Automatically turn emails from your customers into cases in Salesforce to track and resolve customer cases quickly.

    To get started with Email to Case : https://help.salesforce.com/articleView?id=How-do-I-get-started-with-Email-to-Case&language=en_US&type=1

    Web To Case
    Gather customer support requests directly from your company’s website and automatically generate up to 5,000 new cases a day with Web-to-Case. This can help your organization respond to customers faster, improving your support team’s productivity

     

    THanks

  • Parul

    Member
    September 16, 2018 at 12:23 pm in reply to: What are wrapper classes in Salesforce?

    A wrapper class is a custom object defined by programmer wherein he defines the wrapper class properties. Consider a custom object in salesforce, what do you have in it? fields right? different fields of different data types. Similarly 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.

     

     

    Thanks

  • Parul

    Member
    September 16, 2018 at 12:23 pm in reply to: What is the use of Remote Action notation in Salesforce?

    The RemoteAction annotation is used in Visualforce page then it is called via JavaScript.

    Ex:

    global with sharing class AccountRemoter {

    public String accountName { get; set; }
    public static Account account { get; set; }
    public AccountRemoter() { } // empty constructor

    @RemoteAction
    global static Account getAccount(String accountName) {
    account = [SELECT Id, Name, Phone, Type, NumberOfEmployees
    FROM Account WHERE Name = :accountName];
    return account;
    }
    }

     

    <script type="text/javascript">
    function getRemoteAccount() {
    var accountName = document.getElementById('acctSearch').value;

    Visualforce.remoting.Manager.invokeAction(
    '{!$RemoteAction.AccountRemoter.getAccount}',
    accountName,
    function(result, event){
    if (event.status) {
    // Get DOM IDs for HTML and Visualforce elements like this
    document.getElementById('remoteAcctId').innerHTML = result.Id
    document.getElementById(
    "{!$Component.block.blockSection.secondItem.acctNumEmployees}"
    ).innerHTML = result.NumberOfEmployees;
    } else if (event.type === 'exception') {
    document.getElementById("responseErrors").innerHTML =
    event.message + "<br/>\n<pre>" + event.where + "</pre>";
    } else {
    document.getElementById("responseErrors").innerHTML = event.message;
    }
    },
    {escape: true}
    );
    }
    </script>

     

    THanks

  • Parul

    Member
    September 16, 2018 at 12:21 pm in reply to: What are s-controls?

    An s-control can contain any type of content that you can display or run in a browser, for example, a Java applet, an ActiveX control, an Excel file, or a custom HTML Web form.

    It provide a flexible, open means of extending the Salesforce user interface, including the ability to create and display your own custom data forms.

     

    Thanks

  • Parul

    Member
    September 16, 2018 at 12:20 pm in reply to: How can I edit/delete namespace prefix, defined for my managed packages?

    You cannot change once it is defined in dev org you have only one option you need to create a new org and then move your components over there.

     

     

    Thanks

  • Hi

    Apex:outputLink: A link to a URL. apex:outputLink component is rendered in HTML as an anchor tag with an href attribute. Like its HTML equivalent, the body of an <apex:outputLink> is the text or image that displays as the link. To add query string parameters to a link, use nested <apex:param> components.

    Example:

    <apex:outputLink value="https://www.salesforce.com" id="theLink">www.salesforce.com</apex:outputLink>

     

    apex:commandLink – A link that executes an action defined by a controller, and then either refreshes the current page, or navigates to a different page based on the PageReference variable that is returned by the action.
    An <apex:commandLink> component must always be a child of an <apex:form> component.
    To add request parameters to an <apex:commandLink>, use nested <apex:param> components.

    <apex:commandLink value="Google" action="https://www.google.co.in"/><apex:commandLink value="Delete" action="{!dodelete}">
    <apex:param name="eid" value="{!E.Id}" assignTo="{!rId}"/>
    </apex:commandLink>

     

    Thanks

  • Parul

    Member
    September 16, 2018 at 7:21 am in reply to: How to add images to lightning salesforce page?

    The $Resource global value provider you to reference images, style sheets, and JavaScript code you’ve uploaded in static resources.

    <aura:component>
    <!– Stand-alone static resources –>
    <img src=”{!$Resource.generic_profile_svg}”/>
    <img src=”{!$Resource.yourNamespace__generic_profile_svg}”/>

    <!– Asset from an archive static resource –>
    <img src=”{!$Resource.SLDSv2 + ‘/assets/images/avatar1.jpg’}”/>
    <img src=”{!$Resource.yourNamespace__SLDSv2 + ‘/assets/images/avatar1.jpg’}”/>
    </aura:component>

    Thanks

  • Parul

    Member
    September 16, 2018 at 7:17 am in reply to: Can we write visualforce tags inside java script function in Salesforce?

    Hi

    you have to use static resource name like <script src="{!$Resource.jquery}"></script> . Or by include script like <apex:includeScript value="{!$Resource.jquery}"/>

     

    Thanks

     

  • trigger UpdateAccField on Contact (after insert,after update) {

    List<Id> AccID = New List<Id>();
    for(Contact con : Trigger.new){
    if(con.AccountId != null){
    AccID.add(con.AccountId);
    }
    }

    List<contact> con = [SELECT Id,LastName, Account.Name, Account.Id FROM Contact WHERE Account.Id != null] ;
    List<Account> acc = new List<Account>();
    for(Contact s : Triger.new)
    {
    Account a = new Account();
    a.Id = s.AccountId;
    a.Name = s.Account.Name+s.LastName;
    System.debug(‘aaa’+a.Id);
    acc.add(a);
    }
    update acc;
    }

     

    Thanks

  • Parul

    Member
    September 16, 2018 at 6:22 am in reply to: What is the difference between Salesforce Batches and Queueable Apex?

    Batchable Apex:

    If it is a long-running complex process then you should go for Batchable Apex and you can have an option to schedule the batch to run at a customized time.
    It can process up to 50 million records in asynchronous mode.
    5 concurrent jobs are allowed to run at a time and future methods are not allowed in Batch class.
    Batch Class should implement Database.Batchable interface and it should have three methods start(), execute() and finish() methods.

    Queueable Apex:

    It comes in handy, when you need to have both the operations of Batch and future method and it should implement Queueable Interface.
    If one job is dependent on other job means here we can chain the dependent job in execute method by system.enqueuejob(new secondJob());
    You can also able to chain upto 50 jobs and in developer edition you can able to chain up to 5 jobs only.
    It will accept non-primitive types like sObjects and it also runs in asynchronous mode.
    In this Queueable apex you can get Job Id to monitor the job progress.

    Thanks

  • Parul

    Member
    September 16, 2018 at 6:19 am in reply to: Things to remember while writing test class in Salesforce?

    All test methods should reside in a separate class from the class in which the method being tested resides.
    These classes should be appended with the word Test followed by the name of the class being tested, e.g. OpportunityServicesTest.
    These classes should all use the @isTest annotation.
    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.”
    There should be a minimum of “Null Pointer Exception test” as part of negative testing for each method, especially the methods that accept parameters.
    A method without an assert statement is not considered a test method. A large number of relevant assert statements increases confidence in the correct behavior of business logic.
    There should be a comment with each assert statement explaining what is being tested and what the expected output is
    Only use isTest(SeeAllData = true) on class methods in exceptional cases where there are sObjects that don't allow DML operation e.g. PriceBook creation
    No hardcoded ids of any sObject in any test method.
    If a Constant needs to be asserted, it's 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
    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.
    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.
    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_”.
    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
    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.
    Any exceptions that are caught in the production methods should be tested by feeding the test data that throws an exception. Exception Type and the error message should be asserted.
    Every class should have test coverage close to 95% as possible. The focus should be on asserting method behavior rather than increasing coverage. There are very few instances where a method behavior is not straightforward to reproduce and hence test. These should be properly commented.

     

    Thanks

  • Parul

    Member
    September 16, 2018 at 6:15 am in reply to: What is CSV (comma separated values) file in salesforce?

    .CSV format is used, however Salesforce takes the Comma in Comma separated Values very literally. In salesforce when we want to import and export data, we use the csv file.is a simple file format used to store tabular data, such as a spreadsheet or database. Files in the CSV format can be imported to and exported from programs that store data in tables.

     

    Thanks

     

     

  • Parul

    Member
    September 16, 2018 at 5:19 am in reply to: What is Global Picklist ? And Why do we use it in Salesforce?

    Salesforce provides a way to create a custom Picklist on any Object or modify any existing Picklist values. But such type of Picklist is limited for that particular object and no other objects. Salesforce provides a flexibility to use “Global Picklist” value sets to share values across objects and custom Picklist fields and to restrict the Picklist to only the values that you specify.

    A global Picklist value set is a restricted Picklist by nature. Only a Salesforce administrator can add to or modify its values. Each value set can have total 1000 values including both active and inactive and each salesforce org can have 500 global Picklist value sets.
    Thus, we can create a Global Picklist value set to specify Org wide common details like Country codes, business product specific properties which can be shared by any other object in the Org.

     

    Thanks

  • Parul

    Member
    September 16, 2018 at 5:11 am in reply to: Why 'after undelete' trigger is not included in salesforce?

    ‘after undelete’ trigger is included in salesforce but it's available in Salesforce only for the limited set of objects. For Example:

    Count the contact on Account in all four DML operation(Insert, Update, Delete, Undelete).

     

     

    Thanks

  • Parul

    Member
    September 16, 2018 at 5:06 am in reply to: What is the working of Map in Salesforce?

    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.

     

     

    Thanks

  • Parul

    Member
    September 16, 2018 at 5:03 am in reply to: What is SOSL query ? How it works?

    Salesforce Object Search Language (SOSL) is a simple language for searching across all multiple persisted objects simultaneously.

    Sosl statements evaluate to a list of SObjects where each list contains the search results for a particular sobject type.
    SOSL queries are only supported in apex classes and anonymous blocks.
    We can not use a SOSL query in trigger.

    EX:-
    The following example that searches all fields across all account and contact objects.

    List<List< Sobject>> searchList = [FIND ‘Text*’  IN ALL FIELDS RETURNING Account,Contact];
    system.debug(‘searchlist is :’+searchList );

     

    Thanks

  • Yes, you can use Lookup Relationship for creating a Many-To-Many relationship, but, it will not support entire feature of Many-To-Many concept. In other words, using Master-Detail Relationship for creating Many-To-Many Relationship gives you an ideal feature of Many-To-Many. Here are the features which you will not get with lookup relationship.

    If these features are not required or adjusted somehow by your custom code, then both options will work. But, Master-Detail solution is always the ideal solution.

     

    Thanks

  • Parul

    Member
    September 16, 2018 at 4:47 am in reply to: How to use IN clause in Dynamic query?

    Hi

    list<string> setAccIds = new list<string>();
    setAccIds .addAll(AcctoCon_Sync.keySet());

    AccQuery = 'SELECT Id ,AccArticleId , ' + title + ',' + answer + ' FROM ' + articleType;
    AccQuery += ' WHERE PublishStatus = \'Online\' AND language = \'en_US\' AND AccQuery IN :' + setAccIds ;

     

    Thanks

  • Component Events 
    Components events can be handled by same component or component which is present in containment hierarchy (component that instantiates or contain component).
    Below is syntax for creating component event.

    <aura:event type="COMPONENT" description="Event template" >

    <aura:attribute name="msg" type="String" access="GLOBAL"/>

    </aura:event>

    Below is syntax for firing component events from javascript controller.

    var accidentEvent = component.getEvent("newCarAccident"); accidentEvent.setParams({"msg":"New Message!!!."});

    accidentEvent.fire();

    While handling component events, we need to specify name attribute in

    <aura:handler>

    <aura:handler action="{!c.handleNotification}" event="c:carAccidentComponentEvent" name="newCarAccident">

    Make sure that name attribute is same as that of name attribute while registering the event.

     

    Application Events

    This kind of events can be handled by any component which is listening to it (have handler defined for event). It is kind of publish-subscribe modal.
    Below is syntax of creating application event.

    <aura:event type="APPLICATION" description="Event template" >                                                     <aura:attribute name="msg" type="String" access="GLOBAL"/>

    </aura:event>

    Below is syntax to file application events from javascript controller.

    var appEvent = $A.get("e.c:carAccidentAppEvent");

    appEvent.setParams({"msg":"New Message!!!."});

    appEvent.fire();

    While handling application events, no need to specify name attribute in <aura:handler> 

    <aura:handler event="c:carAccidentAppEvent" action="{!c.handleNotification}"/>

     

    Thanks

  • Parul

    Member
    September 16, 2018 at 4:29 am in reply to: How to query email and images from feedItems in case object?

    Hi

     

    I am not able to do this can you explain me how to get parentId.

     

     

    Thanks

  • Parul

    Member
    September 15, 2018 at 7:31 pm in reply to: Does trigger run batches?

    Yes, you can run batches using trigger.

    For example:

    we have an object called AccountUpdates, in that object we have a picklist field called Status. when the Informatica daily load are completed they will insert one record into AccountUpdates object and put the status value to "Acc Load Completed" and save the record.

     

    based on the that status field value trigger(after insert or after update) will fire and run the batch apex.

     

     

    Thanks

  • Hi

    If you want to create master detail on that child object with existing records then first you need to create to convert lookup to master-detail.

     

     

    Thanks

  • Parul

    Member
    September 15, 2018 at 7:24 pm in reply to: What is the relationship between Account and Contact?(Explain)

    Contacts and Accounts have a lookup relationship but this relationship has a property called CascadeDelete that's why the contact is deleted when the parent object is deleted. Account and contact behaves as master detail logics its a standard functionality in salesforce but on UI it is a lookup relationship .

     

    Thanks

  • Parul

    Member
    September 15, 2018 at 4:54 pm in reply to: What is the use of apex param?

    <apex:param> tag is mainly used to pass values from JavaScript to an Apex controller.

     

    Thanks

Page 41 of 53