• Amit Chaudhary 8
  • ALL STAR
  • 35117 Points
  • Member since 2014
  • Salesforce CRM Consultant


  • Chatter
    Feed
  • 1052
    Best Answers
  • 1
    Likes Received
  • 32
    Likes Given
  • 3
    Questions
  • 5050
    Replies
Hello All,
I am unable to extract a field value from the Account page and append it to my Endpoint.  Any suggestion would be greatly appreciated.
Thanks - M

public with sharing class JDECalloutcontroller {
    
    Account currentRecord;
    
    public JDECalloutcontroller (ApexPages.StandardController controller) {
        currentRecord = [SELECT JDE__c FROM Account  WHERE Id = :ApexPages.currentPage().getParameters().get('id')];
    }

    public Account getcurrentRecord(){
        return currentRecord;
    }
    
    public List<JDEwrapper> JDEWrapperList{get;set;}
    public List<JDEwrapper> getperformcallout(){


    JDEWrapperList = new List<JDEwrapper>();
    HttpRequest req = new HttpRequest();
    HttpResponse res = new HttpResponse();
    
   
    Http http = new Http();
    req.setEndpoint('https://blablabla/'+currentRecord );
    

    req.setMethod('GET');
    res = http.send(req);

    if(res.getstatusCode() == 200 && res.getbody() != null){

    JDEWrapperList=(List<JDEwrapper>)json.deserialize(res.getbody(),List<JDEwrapper>.class);

    }
    return JDEWrapperList;
    }
}
Okay...what is staring me in the face that I'm missing here? It's saying this on line 18
 
// Send follow up notification to ERC team
trigger outpatientFollowUp on Opportunity (before insert, before update) {
  // Get Oppy record that has just changed to admitted
  Set<Id> admOpp = new Set<Id>();
  for (Opportunity oppLoop : Trigger.new) {
    if (oppLoop.StageName == 'Admitted' && oppLoop.Admission_Date__c != null) {
      admOpp.add(oppLoop.Id);
    }
  }

  // Get ERC Treatment Team Members
  Map<Id,ERC_Treatment_Member__c> ercTTsmap = new Map<Id,ERC_Treatment_Member__c>([SELECT Id, Provider_Email__c FROM ERC_Treatment_Member__c WHERE Admission__c IN:admOpp]);
    Set<Id> ercTTs = ercTTsmap.keyset();
    
  // Create a master list to hold the emails to send
  List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
  
      for (ERC_Treatment_Member__c teamMember : ercTTs) {
    if (teamMember.Provider_Email__c != null) {

      // Create new Email
      Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
    
      // Set list of people who should get the email
      List<String> sendTo = new List<String>();
      sendTo.add(teamMember.Provider_Email__c);
      mail.setToAddresses(sendTo);

      // Set ID of template
      mail.setTemplateId('00X0G000001jlXV');
    
      // Set who the email is sent from
      mail.setReplyTo('lauren.ake@eatingrecovery.com');
    
      // Add email to master list
      mails.add(mail);
    }
  }
  // Send all emails
  Messaging.sendEmail(mails);
}

 
Hi,

Anybody know why project points are showing as orange instead of green and/or how to take care of it so it shows up as green again?

Thanks!

User-added image
Hi Awesome Developers!

This is my first trigger (first one for a my job anyways) and I want to make sure I wrote it efficiently. My test class is yeidling the expected results. I'm basically putting a list of products families from active opportunities (closed won and in the subscription date range) on the Account object. I'm also putting Active MRR (monthly recurring revenue) on the account.

The part I have the question about is each time I go through the loop, I loop through every opportunity to ensure I only calculate on the opportunities related to the current account. It seems inefficient to me. Is there a better way to do this. Please don't hold back and critiques or observations as I am learning and appreciative! Thanks so much!
 
trigger UpdateProductMix on Account (before update) {
    //System.debug('Trigger Account ID: ' + acct.Id);
            
    List<Opportunity> opps = [SELECT id, Account.Id, Opportunity_MRR__c, (SELECT Id, PricebookEntry.Product2.Family FROM OpportunityLineItems) FROM Opportunity 
                              WHERE AccountId IN :Trigger.New AND StageName = 'Closed Won' 
                              AND Subscription_Start_Date__c <= TODAY 
                              AND Subscription_Current_Expiration_Date__c >= TODAY];
    
    for(Account acct:Trigger.New){
        //Initialize variables
        String prodMix = '';
        Set<String> families = new Set<String>();
        Decimal mrr = 0.00;
        
        // Process the query results
        for(Opportunity o:opps){
            if(acct.Id == o.AccountId){
                //System.debug('o.Opportunity_MRR__c' + o.Opportunity_MRR__c);
                mrr += o.Opportunity_MRR__c; //Add opp MRR of all active opps
                for(OpportunityLineItem oli:o.OpportunityLineItems){
                    if(!families.contains(oli.PricebookEntry.Product2.Family)){
                        //System.debug('oli.PricebookEntry.Product2.Family: ' + oli.PricebookEntry.Product2.Family);
                        families.add(oli.PricebookEntry.Product2.Family); //Add each unique product family to the set
                    }
                }
            }
        }
        
        acct.Active_MRR__c = mrr; //Set the MRR on the account
        
        List<String> famList = new List<String>(families); //Convert set to list so we can sort that bad boy
        famList.sort(); // Sort magic
        
        //Create the product mix string
        for(String family:famList){
            prodMix += family + ', ';
        }
        System.debug('prodMix.length: ' + prodMix.length());   
        if (prodMix.length() > 0){
            acct.Current_Products__c = prodMix.substring(0,prodMix.length()-2); //Trim the final comma and space and set
        } else{
            acct.Current_Products__c = 'No active products';
        }
        
    }
}

 
I got frustrated trying to deploy a simple before-delete trigger because it doesn't matter if the code coverage for the trigger is 40% in the sandbox (you only need 1% for triggers) because in production it always drops down to 0% and I cannot deploy it.

I ran all test classes in both production and sandbox environment and they have 94% and 84% code coverage, respectively. What went wrong? The trigger is so simple:

A. Trigger

trigger deleteAppeal on Appeal__c (before delete) 
  {
     Profile userProfile = [ SELECT Name FROM Profile WHERE Id = :UserInfo.getProfileId() ];
     if ( userProfile.Name <> 'SYSTEM ADMINISTRATOR' )
     {
        for ( Appeal__c appeal:trigger.old )
        {
           appeal.addError('You cannot delete an Appeal. Please ask your System Administrator to do it for you.');
        
        }
       
     }
    }

B. Test class:

@isTest
private class DeleteAppealTriggerTest
{   
    
        
    

    static testMethod void deleteAppealTest()
    {
          
    Case tmpDocket = new Case();
    tmpDocket.Date_Of_Claim__c = Date.newInstance( 2014, 4, 6 ); // MUST be a sunday for validation
    insert tmpDocket;

    Appeal__c tmpAppeal = new Appeal__c();
    tmpAppeal.Case__c = tmpDocket.Id;
            
        insert tmpAppeal;

        Test.startTest();
        
        try
        {
            delete tmpAppeal;
         }
         catch(Exception e) 
     {
         system.assertEquals('Appeal cannot be deleted.', e.getMessage());
         }

        Test.stopTest();

        
      }
    
    
}


HELP!!
 
Hi All,

I'm new to apex coding and wrote my first trigger. I'm not sure how to go about writing a test class. I read up a couple of different forums but haven't been able to figure it out.

trigger OpenRepairs on Repair_History__c (before insert, before update) {
    for (Repair_History__c R: Trigger.new) {
        if (R.Status__c == 'Closed') {
            R.OpenRepair__c = null;
        } else if (R.Status__c == 'Closed - Traded In') {
            R.OpenRepair__c = null;
        } else if (R.Status__c == 'Closed - Return Unrepair') {
            R.OpenRepair__c = null;
        } else if (R.Account__c != null) {
            R.OpenRepair__c = R.Account__c;
        }
    }
}
Can someone please help me to get the SOQL (on opportunity object) from the for loop? I understand that we cannot have soql inside a for loop. Thanks a lot!!

      for (CampaignMember cm: cms) {
          oldcm= (CampaignMember)oldlist[i];
             //Update Opportunity Amount  
             o = [Select ID, Contact__c, CloseDate, CampaignID, OE_Program_of_Interest__c, Amount, Cvent_Balance_Due__c, Amount_Paid__c,       Description, StageName from Opportunity where Contact__c = :cm.ContactID and  Campaign.ID = :cm.CampaignId limit 1];       
             if(o.size() == 1){
                if(cm.Cost__c != oldcm.Cost__c){o[0].Amount = cm.Cost__c;}
                if(cm.Amount_Paid__c != oldcm.Amount_Paid__c){o[0].Amount_Paid__c = cm.Amount_Paid__c;}
                if(cm.Balance_Due__c != oldcm.Balance_Due__c){o[0].Cvent_Balance_Due__c = cm.Balance_Due__c;}                
                if(cm.Status != oldcm.Status && cm.Status == 'Registered'){o[0].StageName = 'Closed Won';}
                if(cm.Payment_Status__c != oldcm.Payment_Status__c && cm.Payment_Status__c == 'Paid in Full'){o[0].StageName = 'Closed Paid';} 
                if(cm.Status != oldcm.Status && (cm.Status == 'Cancelled' || cm.Status == 'Unattended' || cm.Status == 'Withdraw')){o[0].StageName = 'Closed Lost';}
                Updopps.add(o[0]);
             }   
      i++;      
      }
for(Account a : [SELECT Id, Most_Recently_Created_Opportunity_Name__c 
                     FROM Account 
                     WHERE Id IN :accountIdOpportunityMap.keySet()]){
        a.Most_Recently_Created_Opportunity_Name__c = 
                               ((Opportunity) accountIdOpportunityMap.get(a.Id)).Name;
        accounts.add(a);
    }

Hello, there's a bit of APEX syntax I keep running into but I am having trouble comprehending. What does it mean to have [(Opportunity)] in parenthesis in front of the Map instance accountIdOpportunityMap.get(a.Id)? The line I am referencing is line 5.

What type of operation is this? Is there a name for this type of code in parenthesis I can read up on? Thanks!
If Create a vf Page Standard controller Account...take a name field on page...supose  i will enter abc then it will find save record  abc and  related record display on vf page....

Thanks in Advance!!!!
Hi All,

I'm quite new into development and I was looking for answer. We need to have a particular picklist field(Lead_Status__c) in Contact be updated to "Qualified" after the lead was converted with an Opportunity (during conversion of the lead, optionally adding new Opportunity). 

We tried to use workflow and process builder but it end up as "false" in the debug log, so the option is via apex. I manage to do some search in sites and found this code:
 
Trigger Lead on Lead (after update) {

    if (Trigger.isAfter) {

        if (Trigger.isUpdate) { 

            Map<ID,ID> oppToContact = new Map<ID,ID>(); 

            for (Lead ld : Trigger.new) {
                if(ld.isConverted && trigger.oldMap.get(ld.id).isConverted) continue; //only process newly converted leads

                // Find all converted Leads with Opportunitiy and add ConvertedOpportunityId to setConvertedOppIds
                if (ld.ConvertedOpportunityId != null && ld.ConvertedContactId != null){                    
                    oppToContact.put(ld.ConvertedOpportunityId,ld.ConvertedContactID);  

                }

            }
I might need to find the additional code to add here to update the Lead Status in Contact if this particular record was converted from a lead and with added opportunity upon conversion, can anyone please help me on this code? Im quite new in this development and would really like to explore further. Please see image below of the supposed field to update when the Lead converted to Contact and was added opportunity during conversion. field name is Lead_Status__c (picklist field)


User-added image


Thank you for the answer

Israel
I am trying to Bulkify this trigger as we will use data loader in future to insert value in Primary sales rep field and with this existing code this trigger will fail, can you please hepl me in changing the code so that it will not hit governer limits.\

Here i am deleting the sharing permission for the previous assigned user and giving sharing permission to new user.

trigger Sharingupdate on Account (after update) {

    

     

        if(trigger.isUpdate){
            for (Account a : Trigger.old ){
                List<Legal_Doc__c> legaldocu = [Select id From Legal_Doc__c where Accounts__c= : a.id];
                List<Legal_Doc__Share> legdoc = [Select UserOrGroupId From Legal_Doc__Share Where UserOrGroupId =: a.Primary_Sales_Rep2__c and ParentId = :legaldocu ];
        
                                            
                    if(legdoc!= null){
        
                         Delete legdoc;
                                     }
                                    }     
                              } 
        
        
                                    
        
        
         Legal_Doc__Share PrimarysalesrepShr;
         PrimarysalesrepShr = new Legal_Doc__Share();
                   

        
    List<Legal_Doc__Share> legalShrs  = new List<Legal_Doc__Share>();
        for (Account an : Trigger.new ){
        
       
          Legal_Doc__c legaldocum = [Select id From Legal_Doc__c where Accounts__c= :an.id];
               

                    PrimarysalesrepShr.ParentId = legaldocum.Id;
                    PrimarysalesrepShr.UserOrGroupId = an.Primary_Sales_Rep2__c ;
                    PrimarysalesrepShr.AccessLevel = 'edit';

         
                                        }
                          insert PrimarysalesrepShr ;
                                                     }
Hi,

I'm trying to get a child field with SOQL, but I not have success.

I must get the fields of Object Account and Object Product_Account (Child of Account).

I write A query like this:

LIST<Account> accounts = [SELECT Account.Name, (SELECT Product_Account__c.Status__c FROM Product_Account __r) FROM Account];
for(Account account : accounts){
 System.debug('Account Name: ' + account.Name + ', Product Name: '+ HERE I WANT GET THE VALUE FROM "Product_Account__c.Status__c" FIELD);
}

Is it possible to do?

Thanks
Rafael

 
Original question:
I have a trigger I am working on, but I am drawing a blank on how to build a test for it. Any suugestions?
Below is the code for the trigger.

trigger InsertContracts on Account(after update) { 
List<string> contractNum = new List<string>();
Map<String,Account>  contractMap = new Map<String,Account>();
List<BXG_Contract__c> contUpdList = new List<BXG_Contract__c>();

for(Account acc:trigger.new)
{

 contractNum.add(acc.Contract_Number__c);
 contractMap.put(acc.Contract_Number__c,acc);
 
}

for(BXG_Contract__c cont :[select Id, Account__c,BG_Contract_Number__c from BXG_Contract__c where BG_Contract_Number__c IN:contractNum])
{
 if(contractMap.containsKey(cont.BG_Contract_Number__c))
 {
  
  cont.Account__c =contractMap.get(cont.BG_Contract_Number__c).Id;
  contUpdList.add(cont);
 
 }

}
if(contUpdList!=null && contUpdList.size()>0)
{
 Database.Update(contUpdList);

}



//List<BXG_Contract__c> ContractToInsert = new List<BXG_Contract__c>();

    
  /*  for (Account acct : trigger.new) { 
        BXG_Contract__c con =new  BXG_Contract__c();
        
        
        con.Account__c = acct.id;
        
        con.status__c= 'Draft';
        
        con.BG_Contract_Number__c ='7558378' ;
        
        ContractToInsert.add(con);
    } 
    
    Insert ContractToInsert;
    */
    
    
    
   // List<Contract> contracts = [SELECT Id, BG_Contract_Number__c FROM Contract WHERE BG_Contract_Number__c IN: contractNumbersToAccountIds.keySet()];
    //Map<Integer, Id> contractNumberToContractId = new Map<Integer, Id>(); 
  //  for (Contract cont : contracts) { 
  //      cont.AccountId = contractNumbersToAccountIds.get(cont.BG_Contract_Number__c); 
   // } 
   // update contracts; 

}
I had a try-catch block like this in my class,
 
try {
	    	String shref = ApexPages.currentPage().getURL();
	    	System.debug('>>> HouseholdMemberController shref='+shref);
} catch (Exception e) {
			System.debug('>>> ERROR ='+e);
}

Please help me to cover catch block.
Getting this error

Challenge Not yet complete... here's what's wrong: 
There was an unexpected error in your org which is preventing this assessment check from completing: System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Type__c]: [Type__c]
Hello all, 

  I have one urgent requrement, i have two objects integration_object, and integration_staging object , we have callouts to insert record in integration_staging object.after inserting record in the stageing object, i have to replicate all the values in  integration_object objet . for that i have to crate field mapping dynamically and assign values to it. like 

 stagingreclist= new integration_staging ();
for( integration_staging is: stagingreclist)
{
  integration_object  io= new integration_object ();
i0.f1 = 1s.f1;
i0.f2= is.f3;
  i have to map above fields dynamically , 


}


Can any one help me achive scenario or help me better approch for it. your help is very help full for me.
 
public with sharing class DailyDataSourceContactController {
    public ApexPages.StandardController standardController;
    
     public String recordId{get;set;}
        
    public DailyDataSourceContactController(ApexPages.StandardController standardController)
    {
        this.standardController = standardController;        
         buildPage();
    }
    
    private void buildPage(){
      
      recordId = System.currentPagereference().getParameters().get('id');
      ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR, 'This record is read only. The source system of this record is not salesforce.'));
    } 
}

And my visual force page  is

<apex:page standardController="Contact" extensions="DailyDataSourceContactController" >
            
  <apex:outputPanel >
  <div class="row">
      <div class="span12">
          <div class="alert alert-error failureMsg">             
              <strong><apex:pagemessages /></strong>
           </div>
       </div>
   </div>
</apex:outputPanel>


   <apex:detail subject="{!recordId}" relatedList="true" title="true"/> 


</apex:page>
I am trying to complete the Data Modeling Trailhead and am having an issue with "Create Object Relationships." I have confirmed that I created the custom fields for the 'Campsite Relation' object, but it keeps showing me this error. Error message
Campsite Relation object - custom fields created
Any thoughts are greatly appreciated - thank you! 
Hi,

Please help in writing test class for below piece of code. Thanks

public PageReference testFunction(){
        if(testRecord.Shift__c=='Hourly' || testRecord.Shift__c=='Daily'){
            testRecord.Start_Time__c = '8:30 AM';
            testRecord.End_Time__c = '3:30 PM';
        }else if(testRecord.Shift__c=='AM'){
            testRecord.Start_Time__c = '8:30 AM';
            testRecord.End_Time__c = '12:00 PM';
        }
        else if(testRecord.Shift__c=='PM'){
            testRecord.Start_Time__c = '1:00 PM';
            testRecord.End_Time__c = '3:30 PM';
        }
        return null;
    }
Sending an email from a process builder when a condition is true. My business users want to save the email as PDF.

How can I achieve this?

TIA
  • May 15, 2017
  • Like
  • 0
I got to know that , Salesforce has recently introduced the Platform Developer 1 certification (DEV450) to replace the Developer (DEV401) certification. All practitioners, with the DEV401 certification, must complete the DEV450 exam during 2016 to retain a Salesforce developer certification.

Is this true as i dnt not got any email from salesforce / webassessvor that if you will not give the DEV450 exam then your DEV401 certifcate will expire ?
 
When i am posting code "" is not printing. And Some code is removing automatically. 

Any idea . It look like some issue ?
External Lookup Relationship could now be setup between external objects and Salesforce object.
External Object - They are same as custom objects but used to map to data located outside Salesforce.
External object take data from External source and External source obviously has its own DB. 
To create external object : From Setup, click Develop | External Objects.
To create external Data source : Develop | External data source
 
I got to know that , Salesforce has recently introduced the Platform Developer 1 certification (DEV450) to replace the Developer (DEV401) certification. All practitioners, with the DEV401 certification, must complete the DEV450 exam during 2016 to retain a Salesforce developer certification.

Is this true as i dnt not got any email from salesforce / webassessvor that if you will not give the DEV450 exam then your DEV401 certifcate will expire ?
 
This is my test class: 

@IsTest(SeeAllData=true) 
public with sharing class TestInsertDefaultLineItems {
    static testMethod void validateTrigger() {
       Account acc= new Account(Name = 'testAcc', Description='testdesc');
       insert acc;

        //Case record in Test method. 
        Contact conObj = new Contact();
        conObj.lastname = 'testcon';
        conObj.AccountId = acc.id;
        insert conObj;
 
        Opportunity opp1 = new Opportunity (AccountId = acc.Id, Name = 'testOpp', CloseDate = System.today());
            insert opp1;
        
       /* PricebookEntry priceBookEntryNew = new PricebookEntry ();
        Product2 product = new Product2 ();
        PriceBook2 pb2 = new PriceBook2 (Name='Standard priceBook', Description='test');
        insert pb2;      
       List pricebookList = [SELECT Id FROM PriceBook2 WHERE IsStandard = true ];*/
        
     PricebookEntry priceBookEntryNew = new PricebookEntry();
        Product2 product = new Product2(); 
        PriceBook2 pb2 = new PriceBook2 (Name='Standard priceBook',Description = 'test');
        insert pb2;
        List <PriceBook2> pricebookList = [SELECT Id FROM PriceBook2 WHERE IsStandard = true];
        PriceBook2 pricebooktest = new PriceBook2 ();
        if (pricebookList !=null && pricebookList.size()>0)
            pricebooktest = pricebookList.get(0);
        product.name = 'Test';
        insert product;
        
        priceBookEntryNew.Product2Id = product.Id;
        priceBookEntryNew.PriceBook2Id = pricebooktest.Id;
        priceBookEntryNew.UnitPrice = 20.00;
        priceBookEntryNew.UseStandardPrice = false;
        priceBookEntryNew.isactive = true; 
        insert priceBookEntryNew;

        OpportunityLineItem oli = new OpportunityLineItem
            (OpportunityId = opp1.Id,
             PricebookEntryId = priceBookEntryNew.Id,
             Quantity = 1,
             UnitPrice = priceBookEntryNew.UnitPrice,
             
             ServiceDate = System.today()
            );
        insert oli;
    }
}
Hello all, I receive the following message in Trailhead. I think that the exploration and filter are set up properly. I don't know what I am doing wrong. Would you please help?
Hello Developer Community!

I was running this code

List<contact> contactsToChangeOwner = new List<contact>();
for(contact c:[SELECT Id, AccountId, Ownerid, Account.ownerid from contact where  AccountId != null ]){
 
    if(c.ownerid!=c.Account.ownerid){
        c.ownerid = c.Account.ownerid;
        contactsToChangeOwner.add(c);
    }
}

update contactsToChangeOwner;

for 7,780 records to change the contact owners to match the Account Owners and I recieved this error "Apex CPU limit exceeded" what changes can I make to this code to fix this? A map?
iam trying to right trigger im facing issue Variable does not exist: Expense_Report__c at line 5 column 78 on trigger

trigger updatecompany on Region__c(after insert){
            map<Id,Expense_Report__c> mapIds = new map<Id,Expense_Report__c>();
               for(Region__c er : trigger.new){
                    if(er.Company__c != null || er.Company__c != ''){
                        Expense_Report__c reg = new Expense_Report__c(id= er.Expense_Report__c);                     
                        reg.Company__c= er.Company__c;
                        mapIds.put(er.Company__c,reg);
                    }
            }
    if(!mapIds.isEmpty()){
        update mapIds.values();
    }
}
Hello All,
I am unable to extract a field value from the Account page and append it to my Endpoint.  Any suggestion would be greatly appreciated.
Thanks - M

public with sharing class JDECalloutcontroller {
    
    Account currentRecord;
    
    public JDECalloutcontroller (ApexPages.StandardController controller) {
        currentRecord = [SELECT JDE__c FROM Account  WHERE Id = :ApexPages.currentPage().getParameters().get('id')];
    }

    public Account getcurrentRecord(){
        return currentRecord;
    }
    
    public List<JDEwrapper> JDEWrapperList{get;set;}
    public List<JDEwrapper> getperformcallout(){


    JDEWrapperList = new List<JDEwrapper>();
    HttpRequest req = new HttpRequest();
    HttpResponse res = new HttpResponse();
    
   
    Http http = new Http();
    req.setEndpoint('https://blablabla/'+currentRecord );
    

    req.setMethod('GET');
    res = http.send(req);

    if(res.getstatusCode() == 200 && res.getbody() != null){

    JDEWrapperList=(List<JDEwrapper>)json.deserialize(res.getbody(),List<JDEwrapper>.class);

    }
    return JDEWrapperList;
    }
}

Hello all,
 

I have been searching through the documentation and I can't find a clear answer. I am trying to use apex to create a report ( it requires calculations that aren't available in the normal report building ), and I want to be able to save it as a public report. Is this possible? 

If so, would it require a Visualforce Page? 

Hello guys,

I am a beginner and stuck at a simple test class for before delete trigger. Please help me what I am doing wrong.

Trigger code:
trigger NewRandomNumber on Random_Number__c (before delete) {
	Random_Number__c num = New Random_Number__c();

    Integer n = Math.round((100000 + Math.random() * 900000));
	num.Random_number__c = n; 
    
	insert num;
    
}

Test class:
@isTest 

public class TestRandomNumber {
	static testMethod void insertNewRandomNumber() {
        Random_Number__c num = New Random_Number__c();
        Integer n = 624575;
        num.Random_number__c = n;
         test.startTest();

        //insert random number
        insert num;
        
    	test.stopTest();
        
        
        //retrieve the new random number
        num = [SELECT Random_number__c FROM Random_number__c WHERE Id =:num.Id];
       System.debug('New number after delete trigger : ' + num.Random_number__c);
 
       // Test that the trigger correctly updated the number
       System.assertEquals(624575, num.Random_number__c);
   }
}

I tried to cover test for every line of code, but it seems I am doing something wrong as Itis showing 0% of test coverage.

I am trying to pull contentVersion out of one org and push it into another cloud based file storage system and it is providing a lot of challenge given that I am unable to find a way to export the VersionData field for large files.

Has anyone found a way to do this?  Here is what I have tried (and failed):
Batch Apex - failed whenever a file larger than the heap space (12MB for batch) was queried
Bulk API using Java - you are not even allowed to query the VersionData field... wish I knew this before I wrote a whole program to retrieve it...

I am at a loss as to how to export the data in a way that I can rebuild it and upload to another cloud based system.  

 

any help is greatly appreciated as I am going mad :(

  • June 22, 2017
  • Like
  • 0
Hello,

I have noticed that the "Data Management" badge is not showing as complete in my Beginner Developer Trail, but it does show on my dashboard.  I was hoping someone will be able to give me a hand with this? 

Profile:  https://trailhead.salesforce.com/en/users/profiles/00550000006dbpWAAQ

But in the screenshot below, you can see that it shows as incomplete:
User-added image

Thank You,
Janet Post
 

Hi,
I have an after update trigger on the User object.  If the Active checkbox is checked/unchecked, the trigger does not fire.   Any thoughts/ideas on what is happening?  I have seen mixed comments in threads where it seems to work for some people but it isnt working for me.

Thanks

I have the following method which opens a new record page from a VF page. "Account" is a lookup field in the record page which has to be populated from the TR1__Account__c field in the Closing Report object. How do I achieve this? Here is the method I wrote.
public PageReference create() {
        id = ApexPages.currentPage().getParameters().get('id');
           cr = [Select TR1__Account__c from TR1__Closing_Report__c where Id =: id];
        accountId = cr.TR1__Account__c;
        PageReference pageRef = new PageReference('https://foiberia--devv11.cs88.my.salesforce.com/a2w/e?retURL=%2Fa2w%2Fo');
        pageRef.getParameters().put('Account',String.valueOf(accountId));
        return pageRef.setRedirect(true);
    }
Hello everyone,

In QuoteLineItem, i have a custom field : Benefit
Into Quote i have a custom field : total Benefit which is the Sum(Benefit)
Everything fine !
Each time I make a change on QuoteLineItem, i fire a trigger (AFTER insert/Update) in charge to copy the Sum(Benefit) result into the Opportunity.
Problem is that on Opportunity I always have the Previous result of Sum(Benefit) ...

could you help please ?
Thanks you
Hi, 
when I try challenge in module "Formulas & Validations" > "Use Formula Fields" I obtain an error:

Challenge Not yet complete... here's what's wrong: 
There was an unexpected error in your org which is preventing this assessment check from completing: System.DmlException: Delete failed. First exception on row 0 with id 0010Y00000TpZJuQAN; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Cannot delete account with related opportunities.: []


I also delete all opportunities but error still appears

anybody can help me ?

thanks, 
regards
Alessandro
While I am trying to complete Trailhead module for platform events, this is the error message which I am getting.
User-added image

This is the code which I have written as of now,
User-added image
Kindly advise if any changes are required.

Regards
Chetan
I was working on the Customize Your Login Process with My Domain module and I accidentally changed my domain of my Hands-On Org. Is it possible to change it back to what it was? I get an error message now when I try to launch my hands-on org. L

My former Hands On Org. URL is as follows: curious-badger-397879-dev-ed.my.salesforce.com

The domain I changed it to is: mylightsaber.dom-dev-ed.my.salesforce.com
 
NOT (ISPICKVAL( Transfer_ID__r.Transfer_Type__c , 'Store to WHS') AND (Shipping_Quantity__c > Serial_No__r.Quantity_available__c ))

I am getting ) missing in thie validation rule, Can someone help?

System.QueryException: List has more than 1 row for assignment to SObject
Class.AccountSearchUI.<init>: line 13, column 1

My VF Page

<apex:page standardController="Account" extensions="AccountSearchUI">
<head>
<title>Account Search UI</title>
<style type="text/css"> </style>
</head>

<body>
<table width="99%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
    <tr>
        <td height="5" bgcolor="#FFFFFF">&nbsp;</td>
        <td height="5" bgcolor="#FFFFFF">&nbsp;</td>
        <td height="5" bgcolor="#FFFFFF">&nbsp;</td>
    </tr>
    <tr>
        <td bgcolor="#FFFFFF"></td>
        <td bgcolor="#FFFFFF"></td>
        <td bgcolor="#FFFFFF"></td>
      </tr>
    <tr>
        <td height="5" bgcolor="#FFFFFF">&nbsp;</td>
        <td height="5" bgcolor="#FFFFFF">&nbsp;</td>
        <td height="5" bgcolor="#FFFFFF">&nbsp;</td>
    </tr>
    <tr>
    <td bgcolor="#FFFFFF" valign="top">
        <table width="100%" border="0" align="center" cellpadding="1" cellspacing="0" class="tablemain">
            <tr><td height="1"></td></tr>
            <tr><td height="50" class="headingmain">&nbsp;Account Search UI</td></tr>
            <tr>
                <td align="center">
                  <table width="100%" border="0" cellspacing="0" cellpadding="1" class="tablemain">
                    <tr>
                      <td width="10%" height="23" class="headingsub1">Group Org Acc</td>
                      <td width="10%" height="23" class="headingsub1">Vertical</td>
                      <td width="10%" height="23" class="headingsub1">Account Name</td>
                      <td width="10%" height="23" class="headingsub1">Type</td>
                      <td width="10%" height="23" class="headingsub1">Owner Last Name</td>
                      <td width="10%" height="23" class="headingsub1">Client Rank</td>
                      <td width="10%" height="23" class="headingsub1">Account Plan</td>
                      <td width="10%" height="23" class="headingsub1">Last Modified</td>
                      <td width="10%" height="23" class="headingsub1">View Latest PDF</td>
                      <td width="10%" height="23" class="headingsub1">PDF Upload Date</td>
                    </tr>
                    <apex:repeat value="{!accPList}" var="cp">
                    <tr>
                        <td height="23" class="headingsub1"><apex:outputField value="{!cp.Group_Org__c}"/></td>
                        <td height="23" class="headingsub1"><apex:outputField value="{!cp.Vertical__c}"/></td>
                        <td height="23" class="headingsub1"><apex:outputField value="{!cp.Name}"/></td>
                        <td height="23" class="headingsub1"><apex:outputField value="{!cp.Type}"/></td>
                        <td height="23" class="headingsub1"><apex:outputField value="{!cp.Client_Rank__c}"/></td>
                        <td height="23" class="headingsub1"><apex:outputField value="{!cp.Group_Org__c}"/></td>
                        <td height="23" class="headingsub1"><apex:outputField value="{!cp.Vertical__c}"/></td>
                        <td height="23" class="headingsub1"><apex:outputField value="{!cp.Name}"/></td>
                        <td height="23" class="headingsub1"><apex:outputField value="{!cp.Type}"/></td>
                        <td height="23" class="headingsub1"><apex:outputField value="{!cp.Client_Rank__c}"/></td>
                    </tr>
                    </apex:repeat>
          </table>
        </td>
        
      </tr>
    </table></td>
    <td bgcolor="#FFFFFF" valign="top"></td>
    <td bgcolor="#FFFFFF" valign="top"></td>
  </tr>
  
  <tr>
    <td bgcolor="#FFFFFF">&nbsp;</td>
    <td bgcolor="#FFFFFF">&nbsp;</td>
    <td bgcolor="#FFFFFF">&nbsp;</td>
  </tr>

</table>

</body>

</apex:page>

APEX Class
public with sharing class AccountSearchUI{    

    public ApexPages.StandardController stdController {get; set;}
    public Account acc {get; set;}
    public Account accPList {get; set;}
    
    public String accountName ='';
    public AccountSearchUI(ApexPages.StandardController stdController){
    this.stdController = stdController;

 accPList = [select Group_Org__c, Vertical__c, Name, Type, Client_Rank__c from Account where Top_25_Client__c = true and Client_Rank__c < 26 order by Client_Rank__c ASC limit 5];
    }
}
Can anyone help with the issue.
 
This is my code
=============
global class BatchApex implements Database.Batchable<sobject>{
    global Database.QueryLocator start(Database.BatchableContext bc){
        return Database.getQueryLocator('select id from Opportunity');
        
    }
    global void execute(Database.BatchableContext bc,List<Opportunity>scope){
        for(Opportunity o:scope){
            o.Name='sandhya';
        }
    update scope;
}
    global void finish(Database.BatchableContext bc){
            
   Messaging.SingleEmailMessage[] mail=new Messaging.SingleEmailMessage();
        String[] toAddresses=new String[] {'forcesfdcloud@gmail.com'};
            mail.setToAddresses(toAddresses);
        mail.setSubject('sending mail ');
        mail.setPlainTextBody('process completed success fully');
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail});
      
    }
    }
I want to update my opportunities. After updating the opportunities i want to send a mail to the above mentioned address, but it shows error like" Illegal assignment from Messaging.SingleEmailMessage to List<Messaging.SingleEmailMessage>" can any one tell me how to solve this issue.
trigger CheckValidationonCaseClose on Case (after update) {     
for(Case e:Trigger.New){          
Case d=Trigger.oldMap.get(e.Id);         
if(d.Signature_Required__c==true && d.Customer_Signature_Status__c!='Completed' && e.IsClosed==true)
{  
e.adderror('Cannot Close Case');
}

its urgent
}  
Hi,

I have a rquirement to format a time which is given in HH:MM format (24-hour clock) into the user's locale. I assumed that there would be a fromat() method as the DateTime class does, but it does not exist.

Any ideas how I can do this?

Thanks
I have a Salesforce App which passed security review for the first time in the last year. This App also includes integration with external web application, due to this I also submitted a BURP scan report of the external web application. I am not sure about how Salesforce conducts periodic security review and have some queries.

As you may know, Salesforce provides periodic, point-in-time review at an interval determined by salesforce.com (typically anywhere between 6 months to 2 years).

• As per Salesforce documentation for already passed Apps, around the expiry date, Salesforce contacts partners to arrange another review. Can you guide me on how much time Salesforce gives us to prepare for Security Review?

• BURP scan and fixing the issues reported by it can take time. If I could not submit a clean BURP scan report within the time frame provided by Salesforce, Does Salesforce remove package from AppExchange?

• Salesforce charges for Security Review process for paid Apps, as one-time upfront fee, and a small subsequent annual fee. Can you guide me on how much subsequent annual fee Salesforce charges to partners? Salesforce also charges annual listing fee of $150 USD. Is that correct?

Kindly help me with this. Thanks in advance.
Hi All,

I want to disable the global search for particular users,i have disabled the chatter in chatte section,please give me suggestion how to disable the global search.
see the below screen shot where i have disabled
User-added image

see the below screen shot for what i want to disable 

User-added image

Thanks,
Surya
I'm stuck on only one unit for this module; the controlling access to fields unit:

"Two team members need to view and update Accounts, but only one should be able to see and edit the Rating field. Create one profile and one permission set with field level security to solve for this use case.The profile must be named 'Basic Account User' and result in an API name of 'Basic_Account_User'. It should use the 'Salesforce' user license type.
The permission set must be named ‘Account Rating’ and result in an API name of 'Account_Rating'."

"Challenge Not yet complete... here's what's wrong:
The 'Basic Account User' profile did not have the appropriate object and field-level security for the Account object "
  • February 02, 2016
  • Like
  • 1
Hi Jacob,

I have already completed 5 badges, but still no email for obtaining the Cloak of Adventure sweatshirt. Does it take username or email address for sending emails, as my email address and user name are different.

User-added image
Hi,

I want to send an email alert to task owner if they have any open task which due date is already passed.
I want to send it 1 day after due date and 1 week after due date.
Please suggest how I can achieve it because through workflow it is not achievable.

Regards
Emily
 view state and need a steps how can we reduce view state without help of transient
Hi,

I have executed "Run all test" to get code coverage of all apex classes. Is there way to get all apex classes code coverage with percentage copy to excel sheet. I am able to see all classes with percentage in Developer console. But not able to copy all those. Please provide some suggestion.
We are using Apex Data Loader 19.0 and cliq_process.  Using Apex Data Loader & Cliq_process, we are exporting the data into salesforce custom object. The process was working fine past 2 years and till last week. Last few days we are getting the below error.


2015-08-17 06:12:31,218 INFO  [ExportRevenue] process.ProcessRunner run (ProcessRunner.java:104) - Logging in to: https://www.salesforce.com/services/Soap/u/19.0
2015-08-17 06:12:31,233 INFO  [ExportRevenue] client.PartnerClient login (PartnerClient.java:989) - Beginning Partner Salesforce login ....
2015-08-17 06:12:31,249 INFO  [ExportRevenue] client.PartnerClient login (PartnerClient.java:998) - Salesforce login to https://www.salesforce.com/services/Soap/u/19.0/services/Soap/u/19.0 as user forceuser@<company>.com
2015-08-17 06:12:31,655 INFO  [ExportRevenue] dao.DataAccessObjectFactory getDaoInstance (DataAccessObjectFactory.java:51) - Instantiating data access object: C:\Program Files\salesforce.com\Apex Data Loader 19.0\cliq_process\ExportRevenue\write\ExportRevenue.csv of type: csvWrite
2015-08-17 06:12:31,655 INFO  [ExportRevenue] process.ProcessRunner run (ProcessRunner.java:109) - Checking the data access object connection
2015-08-17 06:12:31,655 INFO  [ExportRevenue] process.ProcessRunner run (ProcessRunner.java:114) - Setting field types
2015-08-17 06:12:31,766 ERROR [ExportRevenue] client.PartnerClient describeSObject (PartnerClient.java:1249) - Error while calling web service operation: describeSObject, error was: Failed to send request to https://ncst.my.salesforce.com/services/Soap/u/19.0/00D400000009okc
com.sforce.ws.ConnectionException: Failed to send request to https://<company>.my.salesforce.com/services/Soap/u/19.0/00D400000009okc
    at com.sforce.ws.transport.SoapConnection.send(SoapConnection.java:113)
    at com.sforce.soap.partner.PartnerConnection.describeSObject(PartnerConnection.java:48)
    at com.salesforce.dataloader.client.PartnerClient.describeSObject(PartnerClient.java:1240)
    at com.salesforce.dataloader.client.PartnerClient.setFieldTypes(PartnerClient.java:1196)
    at com.salesforce.dataloader.controller.Controller.setFieldTypes(Controller.java:127)
    at com.salesforce.dataloader.process.ProcessRunner.run(ProcessRunner.java:115)
    at com.salesforce.dataloader.process.ProcessRunner.main(ProcessRunner.java:229)
Caused by: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:150)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1476)
    at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:174)
    at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:168)
    at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:847)
    at com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:106)
    at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Handshaker.java:495)
    at com.sun.net.ssl.internal.ssl.Handshaker.process_record(Handshaker.java:433)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:815)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1025)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1038)
    at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:402)
    at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:170)
    at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:836)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:230)
    at com.sforce.ws.transport.JdkHttpTransport.connectLocal(JdkHttpTransport.java:97)
    at com.sforce.ws.transport.JdkHttpTransport.connect(JdkHttpTransport.java:82)
    at com.sforce.ws.transport.SoapConnection.send(SoapConnection.java:99)
    ... 6 more
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:221)
    at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:145)
    at sun.security.validator.Validator.validate(Validator.java:203)
    at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:172)
    at com.sun.net.ssl.internal.ssl.JsseX509TrustManager.checkServerTrusted(SSLContextImpl.java:320)
    at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:840)
    ... 19 more
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:236)
    at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:194)
    at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:216)
    ... 24 more
2015-08-17 06:12:31,766 FATAL [main] process.ProcessRunner topLevelError (ProcessRunner.java:214) - Unable to run process ExportRevenue
java.lang.RuntimeException: com.sforce.ws.ConnectionException: Failed to send request to https://<company>.my.salesforce.com/services/Soap/u/19.0/00D400000009okc
    at com.salesforce.dataloader.process.ProcessRunner.run(ProcessRunner.java:139)
    at com.salesforce.dataloader.process.ProcessRunner.main(ProcessRunner.java:229)
Caused by: com.sforce.ws.ConnectionException: Failed to send request to https://<company>.my.salesforce.com/services/Soap/u/19.0/00D400000009okc
    at com.sforce.ws.transport.SoapConnection.send(SoapConnection.java:113)
    at com.sforce.soap.partner.PartnerConnection.describeSObject(PartnerConnection.java:48)
    at com.salesforce.dataloader.client.PartnerClient.describeSObject(PartnerClient.java:1240)
    at com.salesforce.dataloader.client.PartnerClient.setFieldTypes(PartnerClient.java:1196)
    at com.salesforce.dataloader.controller.Controller.setFieldTypes(Controller.java:127)
    at com.salesforce.dataloader.process.ProcessRunner.run(ProcessRunner.java:115)
    ... 1 more
Caused by: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:150)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1476)
    at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:174)
    at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:168)
    at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:847)
    at com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:106)
    at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Handshaker.java:495)
    at com.sun.net.ssl.internal.ssl.Handshaker.process_record(Handshaker.java:433)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:815)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1025)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1038)
    at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:402)
    at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:170)
    at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:836)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:230)
    at com.sforce.ws.transport.JdkHttpTransport.connectLocal(JdkHttpTransport.java:97)
    at com.sforce.ws.transport.JdkHttpTransport.connect(JdkHttpTransport.java:82)
    at com.sforce.ws.transport.SoapConnection.send(SoapConnection.java:99)
    ... 6 more
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:221)
    at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:145)
Exact replication steps:
1. Create a connected app
2. Add the callback URL to that connected app as the URL of a VF page. For Eg - 'https://c.eu2.visual.force.com/apex/mypage'.
3. Connect to another salesforce org of the same instance.Énter the login details ie username and password
4. Allow permission to the connected app create on your source org to access info about target org by clicking on Állow Button'
5. Instead of redirecting back to source org it redirects me to the target org and tries to open up the page mentioned in the callback url.
6. This issue is coming when my source and target org are on same instance. It works fine when source and target instances are different.
Hello,
I have some queries on release versioning and listing subsequent versions on AppExchange:
  1. Can I release and maintain 2 versions on AppExchange? In other words, if there a v1.0 that is listed on AppExchange, and we release a new version v1.1 that has passed Security Review and ready to be listed on AppExchange, does it automatically replace the v1.0 that was listed earlier? 
  2. Do the existing customer orgs get any notification of a new released version? If yes, does it automatically contain the install link? If not, what is the most preferred practice?
  3. If I deprecate an earlier version, do the customer orgs using this version get a notification to upgrade? Are they forced to upgrade?
  4. If a patch is created for a particular released version, do I have to manually inform all customer orgs using it? Or do they get automatic notifications of the same and can choose to apply the patch as needed?
Thanks in advance!
Hi,

I want to develop an "Open CTI Adapter", where can I find the documentation(API/Library) for the same?

Regards,
Rohan
Hi ,
  
 I'm trying to parse Account records to JSON string. But I'm getting unnecessary data like attributes(type,url) that is not required in String.

Can any one pls help me in how to parse the string to required format.
List<Account> accnts=[Select Name,Phone From Account];
String s=JSON.serialize(accnts);
The resulting output is in below fromat..
{
  "attributes" : {
    "type" : "Account",
    "url" : "/services/data/v34.0/sobjects/Account/00128000002trGGAAY"
  },
  "Name" : "GenePoint",
  "Phone" : "(650) 867-3450",
  "Id" : "00128000002trGGAAY"
}


My requirement is to generate resulting String as below JSON string format.
 
{
  "Name" : "GenePoint",
  "Phone" : "(650) 867-3450",
  "Id" : "00128000002trGGAAY"
}

So that I can minimize the data to to be sent the the client system.

Any help is really appreciated. Thanks in advance.

Regards,
Naveen.
I need to download Contacts Near By component for the trailhead - field sales app project but I am not able to find it on appexchange. Any idea where can I get it from?