Forum Replies Created

Page 33 of 57
  • shariq

    Member
    September 19, 2018 at 12:09 AM in reply to: StandardSetController in salesforce

    Hi,

    Another type of example is like this

     

    Page

    <apex:page standardController="Account" recordsetvar="Accounts extension="AccListController">

    <apex:pageBlock>
    <apex:pageBlockTable value="{!accountList}" var="o">
    <apex:column value="{!o.Name}"/>
    <apex:column value="{!o.Amount}"/>
    </apex:pageBlockTable>
    </apex:pageBlock>

    </apex:page>

     

    Controller

    public class AccListController{
    public List<Account> accountList{get;set;}
    public AccListController(ApexPages.StandardSetController setCon) {
    accountList = new List<Account>();
    Map<Id,SObject> accMap = new Map<Id, SObject>(setCon.getSelected());
    accountList = [SELECT ID, Name FROM Account where ID IN :accMap.keyset()];
    System.debug('###setCon.getrecords()###'+setCon.getrecords());
    }
    }

     

    To test this you have to create a Button from which you call your Visualforce page in the List view of Account and select the accounts you want to get and call that button.

     

    Hope this helps.

  • Hi,

    Main use of this is to unit test the data, that is the actual data to correct data. If not then it throws and errosr which can be custom as well as standard.

    Hope this helps.

  • shariq

    Member
    September 19, 2018 at 12:04 AM in reply to: What is a typical use case flags for Account-Specific hours in Salesforce?

    Hi,

    Account Level Flags allow you to override the default hours specified on an account-by-account basis.

    Account Level Flags can be set individually or en masse. They need not be specified for every Account; the default hours specified above will be used automatically in the absence of Account Level Flags.

    Account Fields
    To get started, add the Case Flags Age 1, Case Flags Age 2, Case Flags Age 3, and Case Flags Age 4 custom fields to your Account page layout(s).

    Use the properties available in Field Level Security (EE and UE only) and Page Layouts to ensure that only the desired profiles can view and edit the values on these fields.

    Hope this helps.

  • shariq

    Member
    September 18, 2018 at 11:54 PM in reply to: What are Duplicate rules in Salesforce?

    Hi,

    To get basics -

    In other words, it's a rule you set up that tells the backend of your salesforce environment what to do when you are trying to create a record that already exists. For each duplicate rule you will need to have at least one matching rule to identify which of your existing records are potential duplicates

    Hope this helps.

  • shariq

    Member
    September 18, 2018 at 11:53 PM in reply to: Can Boolean value be Null or not in Salesforce?

    Hi,

    Additionally, there's a Boolean type, which can be true, false, or null, and can be used in Collections because it inherits from Object. If using the latter, the consumer need always check for null before checking true or false.

    Hope this helps.

  • shariq

    Member
    September 18, 2018 at 11:52 PM in reply to: What are the uses of big objects in Salesforce?

    Hi,

    Big Objects are merely custom objects but with massive data handling capabilities. They can store at least billions of data in them. They are similar to custom objects in some ways but very different in others. The scale of data is what lets Big objects stand apart in the crowd.

    Just like normal Salesforce objects, Big Objects are also standard as well as custom. Example of a standard big object is FieldHistoryArchive, which stores archived field history data for Field Auditing purposes. Custom big objects are created and deployed by you using the Metadata API.

    When can you use a Big Object?

    As a massive data store, Big Objects can be a great help in many cases. Some typical uses of the Big Objects are as follows:

    Audits and Tracking purposes
    Better customer experiences
    Historical Data Archive

    Hope this helps.

  • shariq

    Member
    September 18, 2018 at 11:49 PM in reply to: What is Duplicate Management in Salesforce?

    Hi,

    Use Data.com Duplicate Management to control whether and when users can create duplicate records in Salesforce; customize the logic that's used to identifyduplicates; and create reports on the duplicates that users save. Note: Duplicate Management uses Data.com technology, but does not require a Data.com license.

    Hope this helps.

  • shariq

    Member
    September 18, 2018 at 11:45 PM in reply to: What is SAQL in Salesforce?

    Hi,

    Adding more point to it -

    Introduction
    Most actions you take in Analytics result in one or more SAQL queries. Every lens, dashboard, and explorer action generates and executes a SAQL statement to build the data needed for the visualization.
    Use SAQL in the User Interface
    Use the Analytics Studio user interface to modify existing SAQL queries or write new ones. Writing SAQL queries in the user interface is the easiest way to get started.
    Write Your First Query
    Let's walk through each step of a simple SAQL query.
    Enable SAQL Logs in the Browser
    If you’re using Google Chrome to work with SAQL and Einstein Analytics, you can turn on SAQL logs

    Hope this helps.

  • shariq

    Member
    September 18, 2018 at 11:42 PM in reply to: lightning:card in salesforce.

    Hi,

    To get into basics -

    Cards are used to apply a container around a related grouping of information.

     

    Example -

    <aura:component> <lightning:card footer="Card Footer" title="Hello"> <aura:set attribute="actions"> <lightning:button label="New"/> </aura:set> <p class="slds-p-horizontal_small"> Card Body (custom component) </p> </lightning:card> </aura:component>

    Hope this helps.

  • shariq

    Member
    September 18, 2018 at 11:27 PM in reply to: In how many ways we can share a record in Salesforce? Explain briefly.

    Hi,

    20 Ways to Share Records in Salesforce

    If the Organization Wide Settings (OWD)  in your Salesforce Org is set to anything other than “Public Read/Write” for any of the standard or custom objects then it is more than likely that you will need to setup some sharing rules to share these records with other users. So what are the different ways to share records? Here is a checklist of all the different ways (20 that I could think of) in which you can share records in Salesforce. You can use this as a quick reference guide to help you determine which of these options will be most appropriate to meet your business requirements.

     

    Hope this helps.

  • Hi,

    Try to access the isPersonAccount property on an Account and catch any exception that occurs if that property is missing. If an exception is generated then person accounts are disabled. Otherwise they're enabled. To avoid making person accounts required for the package you assign the Account object to an sObject and use sObject.get( 'isPersonAccount' ) rather than accessing that property directly on the Account object.

    This method takes ~3.5ms and negligible heap space in my testing.

    Hope this helps.

  • shariq

    Member
    September 18, 2018 at 11:22 PM in reply to: How to import data extensions into the Salesforce Marketing Cloud?

    Hi,

    Import a list into a data extension in Salesforce Marketing Cloud. Before you can import a file, you need to create a data extension and also the importfile. Your import file must contain a header row and atleast one row of data; it should also be a comma-, tab-, or other character-delimited file.

    Hope this helps.

  • Hi,

    POST is used to create a new entity. “Post” means “after”; if you have a collection of entities and you tack a new one onto its end, you have posted to the collection. You can’t post an existing entity, and it’s common (though not always required) to use the collection’s URI to post. (E.g. you would create a new Quora user named Noah by POSTing to https://quora.com/users as opposed to https://quora.com/users/noah.)
    PATCH is used to update an existing entity with new information. You can’t patch an entity that doesn’t exist. You would use this when you have a simple update to perform, e.g. changing a user’s name.
    Finally, PUT is used to set an entity’s information completely. PUTting is similar to POSTing, except that it will overwrite the entity if already exists or create it otherwise. You could use a PUT to write a user to your database that may already be in it.

    Hope this helps.

  • Hi,

    Visualforce pages must be enabled for mobile use before they can display in these areas of the Salesforce user interface:

    • The navigation menu, via a Visualforce tab
    • The action bar, via a custom action
    • Mobile cards on a record’s related information page
    • Overridden standard buttons, or custom buttons and links
    • Embedded in record detail page layouts
    • Lightning pages
    1. To enable a Visualforce page:
    2. From Setup, enter Visualforce Pages in the Quick Find box, then select Visualforce Pages.
    3. Click Edit for the desired Visualforce page.
    4. Select Available for Lightning Experience, Lightning Communities, and the mobile app then click Save.

    Consider these notes about Visualforce support.

    Standard tabs, custom object tabs, and list views that are overridden with a Visualforce page aren’t supported. The Visualforce page is shown for full site users, but Salesforce app users will see the default Salesforce page for the object. This restriction exists to maintain the Salesforce app experience for objects.
    You can also enable Visualforce pages for the Salesforce app through the metadata API by editing the isAvailableInTouch field on the ApexPage object

    Hope this helps.

  • shariq

    Member
    September 18, 2018 at 11:15 PM in reply to: What is Live Agent Configuration Settings in Salesforce?

    Hi,

    Adding more points to above answer -

    Live Agent configuration settings control the functionality that’s available to agents and their supervisors while agents chat with customers.

    Available in: Salesforce Classic
    Available in: Performance Editions and in Developer Edition orgs that were created after June 14, 2012

    Available in: Unlimited Edition with the Service Cloud

    Available for an additional cost in: Enterprise and Unlimited Editions
    Apply settings when you create or edit a Live Agent configuration.
    Basic Information
    Configure the basic functionality that’s available to agents when they chat with customers.

    SETTING

    Live Agent Configuration Name
    Name of this configuration.

    This configuration name, or a version of it, automatically becomes the Developer Name.
    Developer Name
    Sets the API name for this configuration.
    Chat Capacity
    Indicates how many chats an agent who is assigned to this configuration can be engaged in at the same time.
    Sneak Peek Enabled
    Indicates whether agents can see what a chat customer is typing before the customer sends a chat message.
    Request Sound Enabled
    Indicates whether to play an audio alert when the agent receives a new chat request.
    Disconnect Sound Enabled
    Indicates whether to play an audio alert when a chat is disconnected.
    Notifications Enabled
    Indicates whether to display a desktop alert when an agent receives a new chat request.
    Custom Agent Name
    Sets the agent’s name as it appears to customers in the chat window.

    etc

    Hope this helps.

  • Hi,

    To add Example -

    <apex:page controller="TestMessageController">
    <apex:pageMessages />
    <apex:pageMessage summary="This is apex:message" severity="info" strength="2"/>
    <apex:messages />
    <apex:form >
    <apex:outputLabel value="Test String" /><apex:inputField value="{!test.Name}" id="test"/>
    <br/><apex:message for="test"/>
    </apex:form>
    </apex:page>

    public class TestMessageController{
    public Account test{get;set;}
    public TestMessageController(){
    ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'This is apex:pageMessages'));
    test = new Account();
    test.Id.addError('Correct');
    test.Name.addError('Wrong');
    }
    }

    Hope this helps.

  • shariq

    Member
    September 18, 2018 at 11:06 PM in reply to: What are the Different API's in Salesforce?

    Hi,

    SOAP API: This API is useful to integrate your Salesforce organization data with other application using SOAP.

    Bulk API: This API is useful to work with large number of records (Load or delete large number of records).

    METADATA API: This API is useful to manage build tools and manage customizations.

    Wave Analytics REST API: We can access Wave analytics data sets programmatically by using this API.

    Apex REST API: This API is useful build your own REST API in APEX. This API exposes Apex Classes as RESTful web services.

    Apex SOAP API: This API is useful to create custom SOAP web service. This API exposes Apex Classes as SOAP web service.

    Streaming API: This API provides a stream of data reflecting data changes in your Salesforce organization.

    Tooling API: This API is useful to build custom development tools for force.com applications.

    Chatter REST API: This API is useful access chatter feeds and social data using REST.

    Hope this helps.

  • shariq

    Member
    September 18, 2018 at 11:01 PM in reply to: What are the types of custom events in Salesforce Lightning condition?

    Hi,

    Here is the example -

    Componenet level event

    <aura:event type="COMPONENT" description="Fired when a Contact search is completed">
    <aura:attribute name="contacts" type="Contact[]" description="The result of the search, which could be an empty array"/>
    </aura:event>

    Application level event

    <!--c:aeEvent-->
    <aura:event type="APPLICATION">
    <aura:attribute name="message" type="String"/>
    </aura:event>

    Hope this helps.

  • shariq

    Member
    September 18, 2018 at 10:55 PM in reply to: What is Trigger Factory (Framework for apex triggers) in Salesforce?

    Hi,

    1) One Trigger Per Object
    A single Apex Trigger is all you need for one particular object. If you develop multiple Triggers for a single object, you have no way of controlling the order of execution if those Triggers can run in the same contexts

    2) Logic-less Triggers
    If you write methods in your Triggers, those can’t be exposed for test purposes. You also can’t expose logic to be re-used anywhere else in your org.

    3) Context-Specific Handler Methods
    Create context-specific handler methods in Trigger handlers

    4) Bulkify your Code
    Bulkifying Apex code refers to the concept of making sure the code properly handles more than one record at a time.

    5) Avoid SOQL Queries or DML statements inside FOR Loops
    An individual Apex request gets a maximum of 100 SOQL queries before exceeding that governor limit. So if this trigger is invoked by a batch of more than 100 Account records, the governor limit will throw a runtime exception

    6) Using Collections, Streamlining Queries, and Efficient For Loops
    It is important to use Apex Collections to efficiently query data and store the data in memory. A combination of using collections and streamlining SOQL queries can substantially help writing efficient Apex code and avoid governor limits

    7) Querying Large Data Sets
    The total number of records that can be returned by SOQL queries in a request is 50,000. If returning a large set of queries causes you to exceed your heap limit, then a SOQL query for loop must be used instead. It can process multiple batches of records through the use of internal calls to query and queryMore

    8) Use @future Appropriately
    It is critical to write your Apex code to efficiently handle bulk or many records at a time. This is also true for asynchronous Apex methods (those annotated with the @future keyword). The differences between synchronous and asynchronous Apex can be found

    9) Avoid Hardcoding IDs
    When deploying Apex code between sandbox and production environments, or installing Force.com AppExchange packages, it is essential to avoid hardcoding IDs in the Apex code. By doing so, if the record IDs change between environments, the logic can dynamically identify the proper data to operate against and not fail

    Hope this helps.

  • shariq

    Member
    September 18, 2018 at 10:50 PM in reply to: What is the use of 'apex:actionSupport' in Visualforce page in Salesforce?

    Hi,

    apex:ActionSupport : This component adds Ajax request to any other Visualforce component. Example : Commandlink button has inbuilt AJAX functionality however few components like OutputPanel does not have inbuilt AJAX capabilities. So with the help of this component, we can enable AJAX.

    <apex:outputpanel id=”counter”>
    <apex:outputText value=”Click Me!: {!count}”/>
    <apex:actionSupport event=”onclick” action=”{!incrementCounter}” rerender=”counter” status=”counterStatus”/>
    </apex:outputpanel>

    Hope this helps.

  • shariq

    Member
    September 18, 2018 at 10:48 PM in reply to: What is the method we can use to get the Record Type Id in Salesforce?

    Hi,

    There are two ways to do it -

    • Query on record type by its developer name
    • Id recId = Schema.SObjectType.Object__c.getRecordTypeInfosByName().get(‘recordTypeDeveloperName’).getRecordTypeId();

    Hope this helps.

  • shariq

    Member
    September 18, 2018 at 10:45 PM in reply to: What is the significance of keyset() method of MAP in Salesforce?

    Hi,

    It returns you set of keys in map.

    Hope this helps.

  • shariq

    Member
    September 18, 2018 at 10:43 PM in reply to: What is matrix of variable availability to trigger events in salesforce?

    Hi,

    Context Variable Considerations

    • Be aware of the following considerations for trigger context variables:trigger.new and trigger.old cannot be used in Apex DML operations.
    • You can use an object to change its own field values using trigger.new, but only in before triggers. In all after triggers, trigger.new is not saved, so a runtime exception is thrown.
    • trigger.old is always read-only.
    • You cannot delete trigger.new.

    Trigger.new    Trigger.newMap    Trigger.Old     Trigger.OldMap

    Before Insert                      Yes                     No                             No                       No

    Before Update                    Yes                    Yes                             Yes                     Yes

    Before delete                     Yes                     Yes                           Yes                      Yes

    After Insert                         Yes                    Yes                            No                        No

    After Update                      Yes                    Yes                           Yes                        Yes

    After Delete                       No                      No                           Yes                        No

    After Undelete                   Yes                    Yes                            No                        No

    Hope this helps.

  • shariq

    Member
    September 18, 2018 at 10:35 PM in reply to: How to get "mentionSegmentInput.id" in Salesforce Chatter?

    Hi,

    I this code will explains thing you want -

    List<AccountTeamMember> list_objAcctmem = [SELECT UserId, AccountId, IsDeleted, User.Name FROM AccountTeamMember WHERE AccountId =: objCase.AccountId LIMIT 25];
            ConnectApi.FeedItemInput feedItemInput = new ConnectApi.FeedItemInput();
            //ConnectApi.MentionSegmentInput mentionSegmentInput = new ConnectApi.MentionSegmentInput();
            ConnectApi.MessageBodyInput messageBodyInput = new ConnectApi.MessageBodyInput();
            ConnectApi.TextSegmentInput textSegmentInput = new ConnectApi.TextSegmentInput();
        
            messageBodyInput.messageSegments = new List<ConnectApi.MessageSegmentInput>();
        
            textSegmentInput.text = 'Casenumber ' +objCase.CaseNumber+' with the status '+objCase.Status+' has breached SLA aggrement hours';
            messageBodyInput.messageSegments.add(textSegmentInput);
            
            
            // Mention a group.
            if(list_objAcctmem.size() > 0)
                {                
                    for(AccountTeamMember objAcctmem : list_objAcctmem )
                    {
                        ConnectApi.MentionSegmentInput mentionSegmentInput = new ConnectApi.MentionSegmentInput();
                        mentionSegmentInput.id = objAcctmem.UserId;
                        messageBodyInput.messageSegments.add(mentionSegmentInput);
                    }
                }
            feedItemInput.body = messageBodyInput;
            feedItemInput.feedElementType = ConnectApi.FeedElementType.FeedItem;
        
            // Use a record ID for the subject ID.
            feedItemInput.subjectId = objCase.Id;
        
            ConnectApi.FeedElement feedElement = ConnectApi.ChatterFeeds.postFeedElement(null, feedItemInput, null);

    Hope this helps.

  • shariq

    Member
    September 18, 2018 at 10:33 PM in reply to: How can you edit your record from within the lightning:dataTable itself?

    Hi,

    Try this -

    Component – Markup of your component

    <aura:component implements="force:appHostable,flexipage:availableForAllPageTypes"
                    access="global"
                    controller="AccountController">
        <aura:attribute name="data" type="Object"/>
        <aura:attribute name="columns" type="List"/>
        <aura:attribute name="recordId" type="String"/>
        <!-- This attribute will hold the update records from data table-->
        <aura:attribute name="updatedRecord" type="Object[]" />

        <aura:handler name="init" action="{!c.doInit}" value="{!this}"/>

        <!-- You must define keyField as 'Id' to save the record back in Salesforce
    'onsave' attribute will executed when user clicks on save button -->
        <lightning:card title="Account Editable Datatable">
            <lightning:datatable
                                 aura:id="accountDataTable"
                                 columns="{! v.columns }"
                                 data="{! v.data }"
                                 keyField="Id"
                                 onsave ="{!c.onSave}"
                                 hideCheckboxColumn="true"
                                 onrowaction="{! c.handleRowAction }" />
        </lightning:card>
    </aura:component>
    Client Controller – Handles event of your markup

    ({
        /*
         * This finction defined column header
         * and calls getAccounts helper method for column data
         * editable:'true' will make the column editable
         * */
    doInit : function(component, event, helper) {        
            component.set('v.columns', [
                {label: 'Name', fieldName: 'Name', editable:'true', type: 'text'},
                {label: 'Phone', fieldName: 'Phone', editable:'true', type: 'phone'},
                {label: 'Rating', fieldName: 'Rating', editable:'true', type: 'text'},
                {label: 'Custom Field', fieldName: 'My_Custom_Field__c', editable:'true', type: 'text'}
            ]);        
            helper.getAccounts(component, helper);
        },

        /*
         * This function is calling saveDataTable helper function
         * to save modified records
         * */
        onSave : function (component, event, helper) {
            helper.saveDataTable(component, event, helper);
        }
    })

    Client Helper – Handles server interaction and reusable code

    ({
        getAccounts : function(component, event, helper) {
            var action = component.get("c.getAccounts");
            action.setCallback(this,function(response) {
                var state = response.getState();
                if (state === "SUCCESS") {
                    component.set("v.data", response.getReturnValue());
                }
            });
            $A.enqueueAction(action);
        },

        /*
         * This function get called when user clicks on Save button
         * user can get all modified records
         * and pass them back to server side controller
         * */
        saveDataTable : function(component, event, helper) {
            var editedRecords =  component.find("accountDataTable").get("v.draftValues");
            var totalRecordEdited = editedRecords.length;
            var action = component.get("c.updateAccounts");
            action.setParams({
                'editedAccountList' : editedRecords
            });
            action.setCallback(this,function(response) {
                var state = response.getState();
                if (state === "SUCCESS") {
                    //if update is successful
                    if(response.getReturnValue() === true){
                        helper.showToast({
                            "title": "Record Update",
                            "type": "success",
                            "message": totalRecordEdited+" Account Records Updated"
                        });
                        helper.reloadDataTable();
                    } else{ //if update got failed
                        helper.showToast({
                            "title": "Error!!",
                            "type": "error",
                            "message": "Error in update"
                        });
                    }
                }
            });
            $A.enqueueAction(action);
        },

        /*
         * Show toast with provided params
         * */
        showToast : function(params){
            var toastEvent = $A.get("e.force:showToast");
            if(toastEvent){
                toastEvent.setParams(params);
                toastEvent.fire();
            } else{
                alert(params.message);
            }
        },

        /*
         * reload data table
         * */
        reloadDataTable : function(){
        var refreshEvent = $A.get("e.force:refreshView");
            if(refreshEvent){
                refreshEvent.fire();
            }
        },
    })
    Server Controller – Returns and update record

    public class AccountController {
    @AuraEnabled
        public static List<Account> getAccounts(){
            return [SELECT
                   Id, Name, Phone, Rating, My_Custom_Field__c
                   FROM Account LIMIT 200];
        }

        @AuraEnabled
        public static boolean updateAccounts(List<Account> editedAccountList){
            try{
                update editedAccountList;
                return true;
            } catch(Exception e){
                return false;
            }
        }
    }
    So this is how you can create your own editable lightning data table. Below are few considerations and facts about lightning:dataTable:

    • lightning:dataTable is not supported on mobile devices.
    • The keyField attribute is required to hold unique row id. You should always define keyField=”Id” which means row id will be same as record id and it will make easier to update, view and edit records.
    • You component version needs to be at least on API version 43 for the editable data table. However if you are not using editable columns, then you can run data table from api version 41 onwards.

    Hope this helps.

Page 33 of 57