Forum Replies Created

Page 1 of 3
  • Ravi

    Member
    November 4, 2016 at 1:59 pm in reply to: How to swap 2 different component views in Salesforce Lightning?

    You can do this using lightning event.Lightning event is best way communicate between two components.

    You need to follow these steps for these type of scenario:

    1. Create a main component which will be use as container for two components.
    2. Let suppose you want to swap from component A to component B.First create view for component A in main component.
    3. When you want to swap from component A to B fire an event from A that will be handled bu main component.
    4. Main component will destroy component A and will create Component B.
  • Ravi

    Member
    November 4, 2016 at 1:43 pm in reply to: How to attach file using Salesforce Lightning for Salesforce1?

    Hi Tanu,

    You can do this using base64 encoding . You have to follow these steps.

    1.Use JavaScript's FileReader's readAsDataURL to read the file selected by the file input into a String variable.
    2.Encode the contents using JavaScript's encodeURIComponent function.
    3.Call the @AuraEnabled action with the contents, content type, and the Id of the parent record.
    4.URI decode the contents.
    5.Base64 decode the contents.
    6.Insert the attachment.

  • This keyword used to represent the current instance of the class.We use This keyword to differentiate between class instance variable and local variable.

    Example:

    public class ThisKeywordDemo{
        String str = ‘DefaultValue’;
        public ThisKeywordDemo(String str){
            System.debug(‘–local Value–‘+str);
            System.debug(‘–Current Instance Value–‘+this.str)
            this.str = str;
        }
    }

    The above example has One Instance Variable & One Local Variable or Method parameter with same name.

    str = Refers parameter value.
    this.str = Refers the current instance variable value.

    To execute this class go to Developer Console, paste the below line then click execute.

    ThisKeywordDemo thisExample = new ThisKeywordDemo('test This Keyword');

    • This reply was modified 8 years, 2 months ago by  Ravi.
  • Ravi

    Member
    August 9, 2016 at 8:10 am in reply to: How can we extract all the sobject data in excel from Salesforce?

    You can use Data Loader to export all sobject record from salesforce to your local system and access it by excel .

  • You can create a  validation rule on your object for specific field value.

    You can also create a trigger for this but validation rule is much easier.

  • You can't add Visualforce page in the standard related List.

    Can you explain your situation why you need to add inline vf page  in related list?

  • Ravi

    Member
    August 9, 2016 at 7:57 am in reply to: How can we find the unused method in apex class?

    Here what I do when I need to find out unused method ,classes or any other component  in my org.

    I am assuming that you are using eclipse for your development and you have created  project for your org.

    Go ahead and press Ctrl + H ; it will open a popup , type the component you want to search(method).

    It will show where your components are used in your org ,so by this you can find out usability of your components in the org and proceed further as your requirement.

     

    • This reply was modified 8 years, 3 months ago by  Ravi.
  • Ravi

    Member
    August 6, 2016 at 9:53 am in reply to: Account records do not match

    Hi Bruce,

    I think you are exporting data By selecting Export option which exclude recycle bin's data(deleted record).
    If you want to export all data including deleted record then you should use Export All option.
    So try to export record using Export All option and let me know if you are still getting different number of
    records from report.

    Thanks,
    Ravi

  • Ravi

    Member
    August 4, 2016 at 2:31 am in reply to: How can we check in there is some data or not?

    If you are doing this in Apex class then just use if condition to check field value.

    `If(Sobject.field == 'fieldValue'){
    }

    • This reply was modified 8 years, 3 months ago by  Ravi.
  • Ravi

    Member
    July 29, 2016 at 7:00 am in reply to: Can we insert the accountId in Community User?

    AccountId field is not writable for user you can link account through contact.

    here is the sample code this  might  help you .

    Id p = [select id from profile where name='Partner Community User'].id;

    Account ac = new Account(name ='Grazitti') ;
    insert ac;

    Contact con = new Contact(LastName ='testCon',AccountId = ac.Id);
    insert con;

    User user = new User(alias = 'test123', email='[email protected]',
    emailencodingkey='UTF-8', lastname='Testing', languagelocalekey='en_US',
    localesidkey='en_US', profileid = p, country='United States',IsActive =true,
    ContactId = con.Id,
    timezonesidkey='America/Los_Angeles', username='[email protected]');

    insert user;
    system.runAs(user) {
    // statements to be executed by this test user.
    }

    • This reply was modified 8 years, 4 months ago by  Ravi.
    • This reply was modified 8 years, 4 months ago by  Ravi.
    • This reply was modified 8 years, 4 months ago by  Ravi.
    • This reply was modified 8 years, 4 months ago by  Ravi.
  • Ravi

    Member
    July 28, 2016 at 8:03 pm in reply to: How to pass List as a parameter to script?

    Hi pranav,

    If you are using list of a sobject as getter ,setter in your controller then you can use it directly to your script.

    like

    var objectLis =  {!objectList};

    Second option is:

    1) Create the required list in the Apex Controller

    2) Create a Array in the JavaScript on the Page

    3) Use the repeat tag to populate this javascript.

    4) Use the populated list in any place in the JavaScript.

    Here is the sample code::

      <script>

    var requests = [];

    </script>

    <apex:repeat value="{!privacyRequests}" var="request">

    <script>

    requests.push('{!request}');

    </script>

    </apex:repeat>

     

    <script>

    window.onload = alertRequest;

    function alertRequest(){

    alert(requests[0]);

    }

    </script>

  • Yes you can create dynamic query on custom setting .

    `public List getCustomSettingList(String customSettingName,List FieldList){
    if(FieldList.size()==0)
    return null;
    String soqlQuery = 'SELECT ';
    for(String field:FieldList){
    soqlQuery+=field;
    }
    soqlQuery+' FROM '+customSettingName;
    return Database.query(soqlQuery);
    }`

  • Hi Pranav,

    Yes, you can retrieve all contacts record from your org using salesforce RESTor SOAPApi.
    You can also use salesforce BULK Api if your org has large number of records.
    You can use salesforce workbench to test Rest Api.

  • Ravi

    Member
    July 28, 2016 at 9:51 am in reply to: How to grant permission to user through apex code?

    Hi Pranav,
    You can grant Admin permission to user by enforcing sharing rule (Without sharing)to your Apex class.
    public without sharing YourClassName{
    //Your apex code
    }

  • Ravi

    Member
    July 28, 2016 at 8:02 am in reply to: In what condition we apply the soql query in test class?

    Hi Mohit,
    First scenario where we use SOQL query is to retrive some organization data from salesforce database. In this case you have to make your test class all data visible using (SeeAllData = true). But using this is not recommended since your yout test class may not work in other org.

    // All test methods in this class can access all data.
    @isTest(SeeAllData=true)
    public class TestDataAccessClass {
    // This test accesses an existing account.
    static testmethod void myTestMethod1() {
    // Query an existing account in the organization.
    Account a = [SELECT Id, Name FROM Account WHERE Name='Acme' LIMIT 1];
    System.assert(a != null);
    }

    Other scenario where we use SOQL query is to verify the inserted/updated record.

    public class TestDataAccessClass {

    // This test creates and accesses a new test account.
    static testmethod void myTestMethod1() {
    // Create a test account .
    Account testAccount = new Account();
    testAccount.Name = 'Acme Test';
    insert testAccount;
    // Query the test account that was inserted.
    Account testAccount2 = [SELECT Id, Name FROM Account
    WHERE Name='Acme Test' LIMIT 1];
    System.assert(testAccount2 != null);
    }

    }

    • This reply was modified 8 years, 4 months ago by  Ravi.
  • Ravi

    Member
    July 20, 2016 at 10:53 am in reply to: How to cover test class for wrapper class in Salesforce?

    Hi Mohit,

    Here is an Example that will explain how to write unit test for wrapper class.

    Controller:

    public with sharing class WrapperController {
    public class WrapperClass {
    public String name {get; set;}
    }
    }

    Test Class:

    @isTest
    private class TestWrapperController {
    public static void myUnitTest(){
    WrapperController .WrapperClass wrapper= new WrapperController .WrapperClass ();
    wrapper.name = 'Test Wrapper';
    }
    }

  • Ravi

    Member
    July 20, 2016 at 10:30 am in reply to: How to reRender from child vf page to parent vf page?
    1. add a function in your parent page that executes window.parent.location=

        function refreshParent(){
    window.parent.location.href="/{!$CurrentPage.parameters.id}";
    }

    2. In the child execute:

    window.opener.refreshParent();

  • Ravi

    Member
    July 20, 2016 at 10:04 am in reply to: How to call two or more methods on a single click?

    Hi Tanu,

    • Add semi-colons ; to the end of the function calls in order for them(multiple function) to work.

    <input id="btn" type="button" value="click" onclick="fun1(); fun2();"/>

    • You can create a single function that calls both of those, and then use it in the event.

    function myFunction(){
    fun1();
    fun2();
    }

    <input id="btn" type="button" value="click" onclick="myFunction();"/>

  • Ravi

    Member
    July 18, 2016 at 8:55 am in reply to: Need to convert XML to JSON format in SALESFORCE

    There is no standard way of converting XML to JSON. You can use  third party tools to convert xml to Json and viceversa.

    http://www.utilities-online.info/xmltojson/#.V4yZNbh97IU

  • Ravi

    Member
    July 18, 2016 at 8:49 am in reply to: Function not returning value.please see the code?

    Hi Tanu,

    I don't think of  ISNUMBER() function in java script.

    If you want to  check whether a value is Number use Javascript isNaN() function . This function will return false if a  It's a number.

    var r = isNaN({!Contact.CustomField});
    alert(r);

  • Ravi

    Member
    July 12, 2016 at 4:15 am in reply to: Can we fire triggers in batch execute methods?

    Hi Tanu,

    Only way to fire a trigger by doing some DML operation.You perform a DML operation on sObjects, and the trigger will automatically fire. If your batch apex is performing DML (insert, update, delete, undelete) and you have an active trigger in the system for one of those events, the trigger will fire.

    • This reply was modified 8 years, 4 months ago by  Ravi.
  • Ravi

    Member
    July 5, 2016 at 8:40 am in reply to: How to know the mandatory fields in standard or custom objects?

    In Apex you can check this by global describe :

    Schema.DescribeSObjectResult r = User.sObjectType.getDescribe();
    Map<String,Schema.SObjectField> M = r.fields.getMap();
    for(String fieldName : M.keySet())
    { 
     Schema.SObjectField field = M.get(fieldName);
     Schema.DescribeFieldResult F = field.getDescribe();
     //A nillable field can have empty content. A isNillable Boolean non-nillable field must have a value for the object to be //created or saved. 
     // if F.isNillable() is false then field is mandatory
     Boolean isFieldreq = F.isNillable() ;
     System.debug ('F = ' + fieldName + ' isnul= ' + isFieldreq);
    }
    • This reply was modified 8 years, 4 months ago by  Ravi.
  • Hi Nick,

    You can do  this using salesforce automation tool like  workflow and  Process builder. As per the above requirement you  have to create  multiple workflow rule for each field update(checkbox)  and same goes for process builder.

    I think best way to achieve this to write a trigger on  Agent that will update your checkbox field by checking member name.

    Here is code that I have written that is working fine in my org.

    trigger UpdateAgent on Agent__c (before insert) {

    Set<Id> setOfmember = new set<Id>();
    Map<Id, Badges__c> mapToStoreMemberName;
    String member;

    for(Agent__c agent : trigger.new){
    setOfmember.add(agent.Member__c);
    }

    mapToStoreMemberName= new Map<Id, Badges__c>([select id, Name from Badges__c where id in : setOfmember]);

    for(Agent__c agent : trigger.new){

    member = mapToStoreMemberName.get(agent.Member__c).Name;

    if(member == 'Member Awards'){
    agent.Check_Awards__c = true;
    }
    else if(member == 'Member Paper'){
    agent.Check_Paper__c = true;
    }
    else if(member == 'Member Scissor'){
    agent.Check_Scissor__c = true;
    }
    else if(member == 'Member Water'){
    agent.Check_Water__c = true;
    }

    else if(member == 'Member Air'){
    agent.Check_Air__c = true;
    }

    }

    }

    Please do let me know if you face any issues.

  • Ravi

    Member
    July 1, 2016 at 10:10 am in reply to: Difference between Standalone app , SPA and Salesforce 1 app

    Stand Alone Application

    The standalone applications are the applications that can run only on the one system on which it is being installed. The application which being developed using c and c++ are the standalone application because do not form platform independency.

    Web Application

    A web application or web app is a client–server software application which the client runs in a web browser The UI is rendered on a client machine and Business logic and data storage are on the servers.

    single-page application

    A single-page application (SPA) is a web application that fits on a single web page with the goal of providing a more fluid user experience similar to a desktop application.The appropriate resources are dynamically loaded and added to the page as necessary, usually in response to user actions.

    Salesforce1 App

    Salesforce1 is a new mobile application provided by Salesforce.

  • Ravi

    Member
    July 1, 2016 at 9:18 am in reply to: Do anyone have any idea about mapping external Id in bulk API?

    Hi Surbhi,
    If you are doing upsert operation through Api then you need to map externalId.
    In bulk Api you can map externalId by definng externalIdFieldName during job creation.

    <?xml version="1.0" encoding="UTF-8"?>
    <jobInfo xmlns="http://www.force.com/2009/06/asyncapi/dataload">
    <operation>upsert</operation>
    <object>YourObject</object>
    <externalIdFieldName>ExternalIdField</externalIdFieldName>
    <contentType>CSV</contentType>
    </jobInfo>

Page 1 of 3