• pkulkarni
  • NEWBIE
  • 15 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 8
    Replies
  • How lightnig components are re-used?
  • For example, If I have this - http://sfdcmonkey.com/2017/01/07/custom-lookup-lightning-component/ component in my org, and I want same for Opportunity on different lightning component. How can I use that?
  • How can I call generic component in another component with some parameters?
I need to set inbound REST integration in one of my requirement. Whenever we hit Salesforce URL, it should update some info in Salesforce. I am using GET method and passing parameters in URL.

Here is URL I am hitting from POSTMAN - https://peeke-dev-ed.my.salesforce.com/services/apexrest/SFRen/BreakDownCounter?cust=KonarkRegency&build=A&wTank=T1&wLevel=50

But this gives me error - "errorCode": "INVALID_SESSION_ID"  

When I hit URL(/services/apexrest/SFRen/BreakDownCounter?cust=Greenland County Narhe Gaon&build=A&wTank=T1&wLevel=50) from workbench, it updates records successfully. 

My Apex Class is-
@RestResource(urlMapping='/BreakDownCounter/*')
global with sharing class RESTBreakDownController {
    @HttpGet
    global static void updateWaterLevels(){        
        String accntName=RestContext.request.params.get('cust');
        String buildName=RestContext.request.params.get('build');
        String tankName=RestContext.request.params.get('wTank');
        String waterLevel=RestContext.request.params.get('wLevel');
        
        SFRen__Water_Tank__c wTank=[select Id, SFRen__No_of_Times_Emptied_in_a_Day__c , SFRen__Building__c, SFRen__Max_Capacity__c, SFRen__Today_Water_Use__c, SFRen__Current_Water_Level__c, SFRen__Building__r.SFRen__Account__r.Name, SFRen__Building__r.Name from SFRen__Water_Tank__c where SFRen__Building__r.SFRen__Account__r.Name=:accntName and SFRen__Building__r.Name=:buildName and Name=:tankName limit 1];       
        
        if(wTank!=null){
            SFRen__Tank_Level__c level=new SFRen__Tank_Level__c(SFRen__Reading_Time__c=System.now(),SFRen__Water_Level__c=Decimal.valueOf(    waterLevel),SFRen__Water_Tank__c=wTank.Id);       
            insert level;            
        }       
    }   
}

I am not using any authentication. Am I missing anything in the process? Any help would be much appreciated. Thank you in advance.

I have created a trigger.  After insertion of record i want to show message on new page "record added successfuly" and that page should be called from trigger. How to achieve this?

Hello,

 

     I am beginner in Apex. So, Can any one give me brief information of Apex? like its purpose, advantages over other languages etc... 

 

Thanks....!!!

Hi, All
I am new to salesforce, can anyone help me to get 100% coverage please 


public class MyContactListController 
{
    @AuraEnabled
    public static List<Contact> getContacts(Id recordId) 
    {
        List<Contact> conList = new List<Contact>();
        try{
            System.debug('--'+recordId);
            conList = [Select Id, FirstName, LastName, Email, Phone From Contact Where AccountId = :recordId];
            System.debug('conlist result----> '+conList);
        }
        catch(Exception e){
            System.debug('inside catch Block  -> '+e.getMessage());
        }
        return conList;
    }
}



-----------------------------------------
TestClass
-----------------------------------------
@isTest
public class MyContactListControllerTest {
   
    static testMethod void getContactsTest(){
        Account ac = new Account(Name='Name1');
        Insert ac;
        List<Account> acList = [select id, name from Account where id!=NULL];
        System.assertEquals(true,acList.size()>0);
        MyContactListController.getContacts(acList[0].id);
        List<Case> case_Obj  =  [SELECT Id,CaseNumber,AccountId From Case WHERE AccountId=:acList[0].Id LIMIT 10];
       
        MyContactListController.getContacts(acList[0].Id); 
      
    }
}
I am using lightning:treegrid to display hierarchy of accounts.
When I select a child from the hierarchy and then collapse its parent and expand again - the selection is gone.

This is also reproducible in the lightning component library
https://developer.salesforce.com/docs/component-library/bundle/lightning:treeGrid/example

Expand/Collapse should not affect any selection.
I need to set inbound REST integration in one of my requirement. Whenever we hit Salesforce URL, it should update some info in Salesforce. I am using GET method and passing parameters in URL.

Here is URL I am hitting from POSTMAN - https://peeke-dev-ed.my.salesforce.com/services/apexrest/SFRen/BreakDownCounter?cust=KonarkRegency&build=A&wTank=T1&wLevel=50

But this gives me error - "errorCode": "INVALID_SESSION_ID"  

When I hit URL(/services/apexrest/SFRen/BreakDownCounter?cust=Greenland County Narhe Gaon&build=A&wTank=T1&wLevel=50) from workbench, it updates records successfully. 

My Apex Class is-
@RestResource(urlMapping='/BreakDownCounter/*')
global with sharing class RESTBreakDownController {
    @HttpGet
    global static void updateWaterLevels(){        
        String accntName=RestContext.request.params.get('cust');
        String buildName=RestContext.request.params.get('build');
        String tankName=RestContext.request.params.get('wTank');
        String waterLevel=RestContext.request.params.get('wLevel');
        
        SFRen__Water_Tank__c wTank=[select Id, SFRen__No_of_Times_Emptied_in_a_Day__c , SFRen__Building__c, SFRen__Max_Capacity__c, SFRen__Today_Water_Use__c, SFRen__Current_Water_Level__c, SFRen__Building__r.SFRen__Account__r.Name, SFRen__Building__r.Name from SFRen__Water_Tank__c where SFRen__Building__r.SFRen__Account__r.Name=:accntName and SFRen__Building__r.Name=:buildName and Name=:tankName limit 1];       
        
        if(wTank!=null){
            SFRen__Tank_Level__c level=new SFRen__Tank_Level__c(SFRen__Reading_Time__c=System.now(),SFRen__Water_Level__c=Decimal.valueOf(    waterLevel),SFRen__Water_Tank__c=wTank.Id);       
            insert level;            
        }       
    }   
}

I am not using any authentication. Am I missing anything in the process? Any help would be much appreciated. Thank you in advance.
Hi,
I create a lightning component for the lightning experience record pages. In the customize record page, I drag standard Record Detail component and my componont to the page. In my component, I update some fields of a record. After I save those field, I fire up the e.force:refreshView event. But the standard record detail component did not refresh to show the new value of those field. Is there any way to force to refresh the standard record detail component?

 
I'm experiencing a strange problem that cropped up yesterday morning.  I am suddenly getting a 'page not found' error when trying to access my community in my sandbox org.  I have not changed any of the custom URL settings in weeks and was accessing and using the sandbox community the very night before without issue.

Sandbox: https://sandbox-hirebotics.cs51.force.com/ (<-- page not found error)

Production:  https://robots.hirebotics.com (<-- works fine)

After three phone calls / go-to-meetings with salesforce support they can't figure out what's going on.  Their latest guess is that my product custom URL in sandbox (which is copied into sandbox upon a refresh, which I haven't done in a week) is set to "in development".  But they can't tell me why that's a problem now nor how to change that, assuming that's the problem.  They suggested I post here.  See below.
Custom URL in Sandbox

Now, I also tried spinning out another developers sandbox from my working production org and I'm seeing the exact same problem accessing the login page hosted from this new dev org.

Note that the error page below is being served from my org as the email us link connects to my email address.
Community Error Page

Also, both my sandbox and dev sandbox are hosted on CS51, if that's relevant.

Any idea what's going on?  
 

Hello,

 

     I am beginner in Apex. So, Can any one give me brief information of Apex? like its purpose, advantages over other languages etc... 

 

Thanks....!!!

I've created a trigger, but cannot figure out how to cover the dml exception in my test class. Please help! Trigger & test included below:

 

trigger LeadRespondedToCampaign on CampaignMember (after update) {
//update Lead Score by adding a value (10) to the Lead Responded to Campaign field
//if the Campaign Member Status is "Responded"

    List<id> leadIds=new List<Id>();
   
    for(CampaignMember cm:trigger.new){
        if(cm.LeadId !=null){
            System.debug('Status is ' + cm.Status);
            if(cm.Status=='Responded'){
                leadIds.add(cm.LeadId);
                System.debug('Id is ' + cm.LeadId);
            }
        }
    }
    List<Lead> leads=[SELECT Id, Lead_Responded_to_Campaign__c FROM Lead WHERE Id IN: leadIds];
   
    for(Lead l:leads){
        System.debug('Found lead ' + l);
        l.Lead_Responded_to_Campaign__c=10;
    }
    try{
    update leads;
    System.debug('Leads to update list size ' + leads.size());
    }catch (Dmlexception e){
        system.debug('lead update failed: '+e);
    }
}

 

 

 

@isTest
private class TestLeadRespondedToCampaign {

    static testMethod void testStatusChange() {
        Campaign newc = new Campaign(Name = 'Test Campaign', IsActive = True);
        insert newc;
       
        Lead[] newl = new Lead[]{
            new Lead(FirstName = 'Barbara', LastName = 'Jones', State = 'HI'),
            new Lead(FirstName = 'Tim', LastName = 'McElroy', State = 'NH')
        };
        insert newl;
               
        CampaignMember[] cm = new CampaignMember[]{
            new CampaignMember(CampaignId = newc.id, LeadId = newl[0].id, Status = 'Sent'),
            new CampaignMember(CampaignId = newc.id, LeadId = newl[1].id, Status = 'Sent')
        };
        insert cm;
       
        cm[0].Status = 'Responded';
           Test.StartTest();
        update cm;
           Test.StopTest();
         
          newl = [SELECT id, Lead_Responded_to_Campaign__c FROM Lead WHERE id IN :newl];
          {system.assertEquals(String.valueOf(newl[0].Lead_Responded_to_Campaign__c), '10');
          }
    }
}

 

Thank you!

  • August 18, 2011
  • Like
  • 0