Forum Replies Created

Page 5 of 5
  • Kumar

    Member
    January 5, 2017 at 8:47 am in reply to: how to use wildcards for Soql in salesforce?

    Hi Vikas,

    The % and _ wildcards are supported for the LIKE operator.

    • The % wildcard matches zero or more characters.
    • The _ wildcard matches exactly one character.

    For example in your case, if the accounts in your org have the following names:

    {Direct, ReDirector, UnDirects, UnDir, Dir}

    The first query returns: Direct, ReDirector, UnDirects, UnDir

    The second query returns: Direct, Dir

    The third query returns: Direct

    Hope this helps.

     

  • Kumar

    Member
    January 5, 2017 at 8:39 am in reply to: How to test a class that contains no method in salesforce?

    Hello Sushant,

    You can still test it, because classes that have no defined constructors still have a default constructor. So, your unit test would look like this:

    @isTest static void test() {
    testController c = new testController();
    System.assertNotEquals(null, c.mapName);
    }

     

  • Kumar

    Member
    January 5, 2017 at 8:37 am in reply to: which sandbox is better for development : partial copy or full copy?

    The short answer is neither of them is explicitly used for development.

    We generally use a developer sandbox for development. Partial and full copy are generally used to test your code on real data from production.

    For differentiation between partial and full copy sandboxes,

    Partial Data Sandbox
    Partial Data sandboxes include all of your organisation's metadata and add a selected amount of your production organisation's data that you define using a sandbox template. A Partial Data sandbox is a Developer sandbox plus the data you define in a sandbox template. It includes the reports, dashboards, price books, products, apps, and customizations under Setup (including all of your metadata). Additionally, as defined by your sandbox template, Partial Data sandboxes can include your organisation's standard and custom object records, documents, and attachments up to 5 GB of data and a maximum of 10,000 records per selected object. A Partial Data sandbox is smaller than a Full sandbox and has a shorter refresh interval. You can refresh a Partial Data sandbox every 5 days.

    Full Sandbox
    Full sandboxes copy your entire production organisation and all its data, including standard and custom object records, documents, and attachments. You can refresh a Full sandbox every 29 days.
    Sandbox templates allow you to pick specific objects and data to copy to your sandbox, so you can control the size and content of each sandbox. Sandbox templates are only available for Partial Data or Full sandboxes.

    For more info on when to use which sandbox, you can refer to:

    https://help.salesforce.com/articleView?id=create_test_instance.htm&type=0

    Hope this helps.

  • Kumar

    Member
    January 5, 2017 at 7:00 am in reply to: Implementing client side search using Javascript in salesforce

    Here is my code:

    VF Page:

    <apex:page controller="CustomAccountController">

    <script>
    function search(){
    ApexMethod();
    }

    </script>

    <apex:form >
    <apex:actionFunction name="ApexMethod" action="{!searchAccounts}" reRender="accountTable"/>
    <apex:pageBlock >

    <apex:outputText >Account Name</apex:outputText>
    <apex:inputText value="{!name}" onkeyup="search();"/>
    <apex:pageBlockSection columns="3">

    <apex:pageBlockTable id="accountTable" value="{!accounts}" var="acc">
    <apex:column value="{!acc.Name}"/>
    <apex:column value="{!acc.Id}"/>
    <apex:column value="{!acc.AnnualRevenue}"/>
    </apex:pageBlockTable>

    </apex:pageBlockSection>

    </apex:pageBlock>

    </apex:form>

    </apex:page>

    Controller:

    public class CustomAccountController {

    public list<Account> accounts { get; set; }
    public String name { get; set; }

    public CustomAccountController(){
    accounts = new list<Account>();
    accounts = [Select Name,Id,AnnualRevenue From Account];
    }

    public pageReference searchAccounts(){

    string query = '';

    if(name != ''){

    query = 'Select Name,Id,AnnualRevenue From Account Where Name like \''+name+'%\'';
    accounts = database.query(query);
    }
    else{

    query = 'Select Name,Id,AnnualRevenue From Account';
    accounts = database.query(query);
    }

    return null;
    }
    }

    Note: I have not implemented pagination for this page.

    • This reply was modified 7 years, 11 months ago by  Kumar.
  • Kumar

    Member
    January 4, 2017 at 1:27 pm in reply to: Using SLDS styles in salesforce aura component

    Thanks!

  • Kumar

    Member
    January 4, 2017 at 6:08 am in reply to: Where is the 'force:slds' class in my salesforce org?

    Thnaks, I got it now.

  • Kumar

    Member
    January 4, 2017 at 5:52 am in reply to: Sorting based on column value in salesforce

    Thank you so much! This really helps.

  • Kumar

    Member
    January 3, 2017 at 2:01 pm in reply to: How to use salesforce lightning component in Visualforce

    Thanks!

  • P.S. Its ETL tools, not LTS tools, my mistake.

  • Kumar

    Member
    December 21, 2016 at 8:31 am in reply to: Validations in Salesforce Lightning Form

    It works flawlessly! Thanks

    I used this in a helper for my JS controller, here is my code:

    Component:

    <aura:component controller ="CampingListController">

    <aura:attribute name="items" type="Camping_Item__c[]"/>
    <aura:attribute name="newItem" type="Camping_Item__c"
    default="{ 'sobjectType': 'Camping_Item__c',
    'Name': '',
    'Packed__c': false }"/>

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

    <div class="slds-col slds-col--padded slds-p-top--large">
    <div aria-labelledby="newcampingitemform">

    <!-- BOXED AREA -->
    <fieldset class="slds-box slds-theme--default slds-container--small">

    <legend id="newcampingitemform" class="slds-text-heading--small
    slds-p-vertical--medium">
    Add Camping Item
    </legend>

    <!-- CREATE NEW EXPENSE FORM -->
    <form class="slds-form--stacked">

    <div class="slds-form-element slds-is-required">
    <div class="slds-form-element__control">
    <ui:inputText aura:id="campname" label="Camping Item Name"
    class="slds-input"
    labelClass="slds-form-element__label"
    value="{!v.newItem.Name}"
    required="true"/>
    </div>
    </div>

    <div class="slds-form-element slds-is-required">
    <div class="slds-form-element__control">
    <ui:inputNumber aura:id="quantity" label="Quantity"
    class="slds-input"
    labelClass="slds-form-element__label"
    value="{!v.newItem.Quantity__c}"
    required="true"/>

    </div>
    </div>

    <div class="slds-form-element">
    <div class="slds-form-element__control">
    <ui:inputCurrency aura:id="price" label="Price"
    class="slds-input"
    labelClass="slds-form-element__label"
    value="{!v.newItem.Price__c}"
    required="true"/>
    </div>
    </div>

    <div class="slds-form-element">
    <ui:inputCheckbox aura:id="packed" label="Packed?"
    class="slds-checkbox"
    labelClass="slds-form-element__label"
    value="{!v.newItem.Packed__c}"/>
    </div>

    <div class="slds-form-element">
    <ui:button label="Create Item"
    class="slds-button slds-button--brand"
    press="{!c.saveItem}"/>
    </div>

    </form>
    <!-- / CREATE NEW EXPENSE FORM -->

    </fieldset>
    <!-- / BOXED AREA -->

    </div>
    <!-- / CREATE NEW EXPENSE -->

    </div>

    JS Controller Method:

    saveItem: function(component, event, helper) {

    if(helper.validateCampingItem(component)){
    // Create the new expense
    var newItem = component.get("v.newItem");
    helper.createItem(component, newItem);
    }

    Helper Method:

    validateCampingItem : function(component) {
    var validRecord = true;

    // Name must not be blank
    var nameField = component.find("campname");
    var campname = nameField.get("v.value");
    if ($A.util.isEmpty(campname)){
    validRecord = false;
    nameField.set("v.errors", [{message:"Camping name can't be blank."}]);
    }
    else {
    nameField.set("v.errors", null);
    }
    var quantityField = component.find("quantity");
    var quantity = quantityField.get("v.value");
    if ($A.util.isEmpty(quantity)){
    validRecord = false;
    quantityField.set("v.errors", [{message:"Quantity can't be blank."}]);
    }
    else {
    quantityField.set("v.errors", null);
    }
    var priceField = component.find("price");
    var price = priceField.get("v.value");
    if ($A.util.isEmpty(price)){
    validRecord = false;
    priceField.set("v.errors", [{message:"Price can't be blank."}]);
    }
    else {
    priceField.set("v.errors", null);
    }
    return validRecord;
    },

     

  • Kumar

    Member
    December 21, 2016 at 8:16 am in reply to: Validations in Salesforce Lightning Form

    This is a validation rule for 'Account name is not empty' right?

    Thanks, I will implement this for my lightning form.

  • Kumar

    Member
    December 20, 2016 at 2:11 pm in reply to: Roll up summary to count attachments on Salesforce Opportunity

    Thanks for helping ! I will try to create a trigger.

  • Thanks dude, works flawlessly !

     

  • Kumar

    Member
    December 16, 2016 at 10:14 am in reply to: Returning no. of records processed by a batch class in Salesforce

    Sure, this is the code snippet:

    global class UpdateContactAddresses implements
    Database.Batchable<sObject>, Database.Stateful {

    global Integer recordsProcessed = 0;

    global Database.QueryLocator start(Database.BatchableContext bc) {
    return Database.getQueryLocator('SELECT ID, BillingStreet, BillingCity, BillingState,BillingPostalCode, (SELECT ID, MailingStreet, MailingCity,MailingState,MailingPostalCode FROM Contacts) FROM Account Where BillingCountry = \'USA\'');
    }

    global void execute(Database.BatchableContext bc, List<Account> scope){

    List<Contact> contacts = new List<Contact>();
    for (Account account : scope) {
    for (Contact contact : account.contacts) {
    contact.MailingStreet = account.BillingStreet;
    contact.MailingCity = account.BillingCity;
    contact.MailingState = account.BillingState;
    contact.MailingPostalCode = account.BillingPostalCode;

    contacts.add(contact);

    recordsProcessed = recordsProcessed + 1;
    }
    }
    update contacts;
    }

    global void finish(Database.BatchableContext bc){
    System.debug(recordsProcessed + ' records processed.');
    AsyncApexJob job = [SELECT Id, Status, NumberOfErrors,
    JobItemsProcessed,
    TotalJobItems, CreatedBy.Email
    FROM AsyncApexJob
    WHERE Id = :bc.getJobId()];
    }

    }

     

    • This reply was modified 8 years ago by  Kumar.
  • Kumar

    Member
    December 16, 2016 at 6:53 am in reply to: Can't uninstall package from org in Salesforce

    EDIT: I got it, there is an option to delete inactive processes from the process builder. Silly me!

  • Kumar

    Member
    December 16, 2016 at 4:48 am in reply to: Eclipse project not updating to Developer org in Salesforce

    Thanks for helping !

    • This reply was modified 8 years ago by  Kumar.
  • Kumar

    Member
    December 15, 2016 at 12:34 pm in reply to: Returning no. of records processed by a batch class in Salesforce

    I got it by using database.stateful.

    Thanks again !

  • Kumar

    Member
    December 15, 2016 at 7:56 am in reply to: Returning no. of records processed by a batch class in Salesforce

    Thanks ! I will try to implement database.stateful

    • This reply was modified 8 years ago by  Kumar.
  • Kumar

    Member
    December 14, 2016 at 8:32 am in reply to: What is the difference between public groups and queues in Salesforce?

    Thank you so much !

  • Hi Sushant,

    Unlike DML statements, Database methods have an optional allOrNone parameter that allows you to specify whether the operation should partially succeed. When this parameter is set to false, if errors occur on a partial set of records, the successful records will be committed and errors will be returned for the failed records. Also, no exceptions are thrown with the partial success option.

    For more information, go to

    https://trailhead.salesforce.com/force_com_dev_beginner/apex_database/apex_database_dml

    Hope this helps.

    • This reply was modified 8 years ago by  Kumar.
  • Kumar

    Member
    December 8, 2016 at 11:29 am in reply to: How to typecast a list of Salesforce sObjects into list of Accounts?

    Thanks dude

  • Kumar

    Member
    December 8, 2016 at 11:28 am in reply to: What is Difference between Salesforce Triggers and Workflows?

    Hi sushant,

    1. Workflows are part of standard salesforce customisation, so no code is required. While triggers are a piece of APEX code .
    2. Workflows only work on record creation and updation, while triggers can work on any DML event.
    3. Workflows events include field updates, email alerts, new tasks and outgoing messages only.
    4. You can not create records with workflows, while with triggers you can.

    There are plenty more differences, for more information go to,

    http://salesforce.stackexchange.com/questions/26929/workflows-vs-triggers

     

  • Thanks !!

     

     

  • Kumar

    Member
    December 6, 2016 at 6:22 am in reply to: How to send email attachments through Salesforce Apex code?

    Thanks Pranav !

     

Page 5 of 5