Forum Replies Created

Page 49 of 57
  • Hi,

    For more information, Returning the current page won't run the constructors unless the setRedirect flag is set to true though. From the docs "If the postback request indicates a page redirect and the redirect is to a page that uses the same controller and a proper subset of controller extensions of the originating page, a postback request is executed for that page." In this case, the same controller would be in use as its the same page.

    Hope this helps.

  • Hi,

    Try this -

    String sitename = 'testSiteName';

    Site site = [SELECT GuestUserId FROM Site WHERE Name = :sitename ];

    String sitepath = '/sites/servlet.SiteDebugMode';
    PageReference prRef = new PageReference(sitepath );
    prRef .getParameters().put('guid', site.GuestUserId);
    prRef .getParameters().put('sitedebugmode', 'x');
    String siteurl = prRef .getContent().toString().substringAfter('URL=').substringBefore(sitepath );

    System.debug(siteurl ); //eg "http://dev-bigass.cs81.force.com/testSiteName"

    Hope this helps.

  • shariq

    Member
    September 14, 2018 at 2:08 am in reply to: How can I show a Visualforce page in the sidebar?

    Hi,

    You can achieve this by creating custom home page component and assign your vf page to it.

    Hope this helps.

  • shariq

    Member
    September 14, 2018 at 2:05 am in reply to: How to query records from sObject for 50000+ records?

    Hi,

    You can try this -

    controller - 

    public class StatsController {
        public Integer numberOfContacts {
            get {
                if (numberOfContacts == null) {
                    numberOfContacts = [select count() from Contact];
                }
                return numberOfContacts;
            }
            private set;
        }
    }

    vf page -

    <apex:page controller="StatsController" readOnly="true">
    <p>Number of Contacts: {!numberOfContacts}</p>
    </apex:page>

    Hope this helps.

     

  • shariq

    Member
    September 14, 2018 at 2:02 am in reply to: Not sending emails to some domains from Salesforce

    Hi,

    You can achieve this by saving the domain in database, best is to save it in a custom setting then get those custom setting records when sending a mail.

    Hope this helps.

  • Hi,

    No, You can't duplicate vf page in Salesforce Community.

     

  • shariq

    Member
    September 14, 2018 at 1:56 am in reply to: How to show PickList field as Radio Buttons on Visualforce Page?

    Hi,

    Controller - 

    public class accEx {

    public accEx(ApexPages.StandardController controller) { }

    public List<SelectOption> getTypes(){
    Schema.sObjectType sobject_type = Account.getSObjectType();
    Schema.DescribeSObjectResult sobject_describe = sobject_type.getDescribe();
    Map<String, Schema.SObjectField> field_map = sobject_describe.fields.getMap();
    List<Schema.PicklistEntry> pick_list_values = field_map.get('Active__c').getDescribe().getPickListValues();
    List<selectOption> options = new List<selectOption>();
    for (Schema.PicklistEntry a : pick_list_values) {
    options.add(new selectOption(a.getLabel(), a.getValue()));
    }
    return options;
    }
    }

    vf page - 

    <apex:page standardController="Account" extensions="accEx">
    <apex:form>
    <apex:selectRadio value="{!Account.Active__c}">
    <apex:selectOptions value="{!Types}"></apex:selectOptions>
    </apex:selectRadio>
    </apex:form>
    </apex:page>

    Hope this helps.

  • shariq

    Member
    September 14, 2018 at 1:52 am in reply to: What is AJAX typically used for in Salesforce Visualforce pages?

    Hi,

    AJAX is primarily used for partial page updates in Visualforce.  In s-controls, the AJAX toolkit was the soap (XML over HTTP) client that gave you access to the force.com Web Services API.

    Hope this helps.

  • Hi,

    For best performance, SOQL queries must be selective, particularly for queries inside triggers. To avoid long execution times, the system can terminate nonselective SOQL queries. Developers receive an error message when a non-selective query in a trigger executes against an object that contains more than 200,000 records. To avoid this error, ensure that the query is selective.

    Selective SOQL Query Criteria

    • A query is selective when one of the query filters is on an indexed field and the query filter reduces the resulting number of rows below a system-defined threshold. The performance of the SOQL query improves when two or more filters used in the WHERE clause meet the mentioned conditions.
    • The selectivity threshold is 10% of the first million records and less than 5% of the records after the first million records, up to a maximum of 333,333 records. In some circumstances, for example with a query filter that is an indexed standard field, the threshold can be higher. Also, the selectivity threshold is subject to change.

    Hope this helps.

  • Hi,

    The two main difference between normal and wizard controller  is that wizard handle multiple pages and they maintain the state across those pages.

    Hope this helps.

  • shariq

    Member
    September 14, 2018 at 1:39 am in reply to: What is the difference between Insert and Database.insert in Salesforce?

    Hi,

    Insert is the DML statement which is same as databse.insert. However, database.insert gives more flexibility like rollback, default assignment rules etc. we can achieve the database.insert behavior in insert by using the method setOptions(Database.DMLOptions)

     

    Important Difference:

    If we use the DML statement (insert), then in bulk operation if error occurs, the execution will stop and Apex code throws an error which can be handled in try catch block.

    If DML database methods (Database.insert) used, then if error occurs the remaining records will be inserted / updated means partial DML operation will be done.

    Hope this helps.

  • shariq

    Member
    September 14, 2018 at 1:35 am in reply to: Why can we not perform callout in Salesforce after DML statement?

    Hi,

    Callouts aren't allowed after DML operations in the same transaction because DML operations result in pending uncommitted work that prevents callouts from executing.

    Since Salesforce does not have a explicit Commit, if you try doing DML and then Callout, you will get ‘You have uncommitted work pending. Please commit or rollback before calling out”.

    Hope this helps.

  • shariq

    Member
    September 14, 2018 at 1:29 am in reply to: How to calculate the size of object?

    Hi,

    As a general rule of thumb - regardless of whether you have 10 fields on an object or 80, Salesforce allocates and estimates 2k for more records. This is all about both performance, governor limits and your storage limits.

    Hope this helps.

  • shariq

    Member
    September 14, 2018 at 1:24 am in reply to: Relation Between OpportunityLineitem & Pricebook entry

    Hi,

    1. OpportunitylineItem is junction object between opportunity and pricebookentry.
    As We need PricebookEntry Id and opportunity Id while creating OpportunityLineItems.

    2. PricebookEntry is a junction object between Product2 and PriceBook.
    As we need Product2 Id and PriceBook2 Id while creating PricebookEntries.

    Hope this helps.

  • Hi,

    You need to use apex:selectoption for your requirement.

    <apex:page controller="chooseColor">
    <apex:form>
    <apex:selectList id="chooseColor" value="{!string}" size="1">
    <apex:selectOption itemValue="red" itemLabel="Red"/>
    <apex:selectOption itemValue="white" itemLabel="White"/>
    <apex:selectOption itemValue="blue" itemLabel="Blue"/>
    </apex:selectList>
    </apex:form>
    </apex:page>

    controller -

    public class chooseColor {
    String s = 'blue';

    public String getString() {
    return s;
    }

    public void setString(String s) {
    this.s = s;
    }
    }

    Hope this helps.

  • shariq

    Member
    September 14, 2018 at 1:17 am in reply to: What do {!expressions} refer to when used in Visualforce components?

    Hi,

    We use expressions for dynamic output or passing values into components by assigning them to attributes. A Visualforce expression is same as in other languages (Java, C or C++ etc). It is aset of literal values, variables, sub-expressions, or operators that can be resolved to a single value.

    For Example : - {!x+y} will give you a sum of two getter setter variable(x and y).

    Hope this helps.

  • shariq

    Member
    September 14, 2018 at 1:08 am in reply to: Give an example of a standard object that’s also junction object.

    Hi Avinish,

    For more clarity, we create junction object to have multiple to multiple relationship between other two objects.

    For example :- One product can have multiple price and same price can be on multiple products.

    Hope this helps.

  • shariq

    Member
    September 14, 2018 at 1:03 am in reply to: What is Accordion in Salesforce lightning component?

    Hi,

    In simple language An accordion allows a user to toggle the display of a section of content.

    Salesforce Lightning Accordion:
    lightning accordion component groups related content in a single container. Only one accordion section is expanded at a time. When you select a section, it’s expanded or collapsed. Each section can hold one or more Lightning components.

    Hope this helps.

  • shariq

    Member
    September 14, 2018 at 12:59 am in reply to: What are the static resources in Salesforce?

    Hi,

    Static Resource - It is kind of a memory where you save/upload content that you can reference in a Visualforce page, including archives (such as .zip and .jar files), images, style sheets, JavaScript, and other files.

    Hope this helps.

  • Hi,

    Export button -  all records( excluding records present in Recycle Bin) present in the system for that particular object are exported to a .csv file.

    Export All - all records (including records present in Recycle Bin) for that particular object are exported to a .csv file. Deleted records present in recycle bin are also called ‘soft Deleted’ records.

    Hope this helps.

  • shariq

    Member
    September 14, 2018 at 12:49 am in reply to: display related records in Object view

    Hi,

    Try this -

    <!-- For this example to render properly, you must associate the Visualforce page
    with a valid account record in the URL.
    For example, if 001D000000IRt53 is the account ID, the resulting URL should be:
    https://Salesforce_instance/apex/myPage?id=001D000000IRt53
    See the Visualforce Developer's Guide Quick Start Tutorial for more information. -->

    <apex:page standardController="Account">
    <apex:pageBlock>
    You're looking at some related lists for {!account.name}:
    </apex:pageBlock>

    <apex:relatedList list="Contacts">
    <apex:facet name="header"></apex:facet>
    </apex:relatedList>

    </apex:page>

    Hope this helps.

  • Hi,

    Insert is the DML statement which is same as databse.insert. However, database.insert gives more flexibility like rollback, default assignment rules etc. we can achieve the database.insert behavior in insert by using the method setOptions(Database.DMLOptions)

     

    Important Difference:

    If we use the DML statement (insert), then in bulk operation if error occurs, the execution will stop and Apex code throws an error which can be handled in try catch block.

    If DML database methods (Database.insert) used, then if error occurs the remaining records will be inserted / updated means partial DML operation will be done.

    Hope this helps.

  • shariq

    Member
    September 14, 2018 at 12:40 am in reply to: What is the difference between pageblocktable and datatable in VF pages?

    Hi,

    apex:datatable - 

    • Doesn't Inherit Salesforce styles
    • No <apex:pageBlock> or <apex:pageBlockSection> needed
    • For displaying data we use one or more <apex:column>, CSS styles can be applied
    • Headers need to mentioned Seperately unless like <apex:pageBlockTable>
    • up to 1,000 items.

    apex:pageblocktable - 

    • Inherits Default Salesforce styles
    • must be under <apex:pageBlock> or <apex:pageBlockSection>
    • For displaying data we use one or more <apex:column>
    • up to 1,000 items.

    Hope this helps.

  • shariq

    Member
    September 13, 2018 at 11:36 pm in reply to: What is single sign-on(SSO) in Salesforce?

    Hi,

    To get it more simple, it is process of login without providing the credentials, where we setup the configuration in Source Org(Identity provider) to get into target org(service provider). Identity provider is kind of credential saver for different applications(service providers).

    Hope this helps.

     

  • Hi,

    The minimalist design by your question looks like tFileInputExcel-->tSalesforceOutput.
    For this component you need a field declared as an External Id used by salesforce to decide the action (insert or update) for each record.

    Hope this helps.

Page 49 of 57