+ Start a Discussion
KARIM EL ALAOUIKARIM EL ALAOUI 
I have been configuring ligthning component and its gone well so far. However I am struggling to find out why the new component doesnt display information, we have reclamation custom objet with lookup relation with contact and I need to display all relamations related to a contact in ligthning component under contact, see bellow all config:

ReclamationListController.apxc
public class ReclamationListController {
        
    @AuraEnabled
    public static List<Reclamation__c> getReclamationList(List<Id> contactIds) {
                List<Reclamation__c> reclamationList = [SELECT Id, Name, Type__c, Description__c, Contact__c FROM Reclamation__c WHERE Contact__c in :contactIds];
        return reclamationList;
    }
}
**************************************************
ReclamationList.cmp

<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" controller="ReclamationListController" access="global" >
    <!-- Handler to call function when page is loaded initially -->
    <aura:handler name="init" action="{!c.getReclamationsList}" value="{!this}" />
    <aura:attribute name="reclamationList" type="List" />
        <lightning:card title="Reclamations">
        <p class="slds-p-horizontal_small">       
            <aura:iteration items="{!v.reclamationList}" var="reclamation"> 
                <lightning:recordViewForm recordId="{!reclamation.Id}" objectApiName="Reclamation__c">
                    <div class="slds-box slds-theme_default">
                        <lightning:outputField fieldName="Name" />
                        <lightning:outputField fieldName="Type__c" />
                        <lightning:outputField fieldName="Description__c" />
                    </div>             
                </lightning:recordViewForm>
                <br />
            </aura:iteration>
        </p>

        <aura:set attribute="actions">
            <lightning:button label="New" onclick="{!c.newReclamation}" />
        </aura:set>
    </lightning:card>
</aura:component>
**************************************************************
ReclamationsListController.js

({

        getReclamationsList : function(component, event, helper) {

                helper.fetchReclamations(component, event, helper);
        },

    newReclamation: function(component, event, helper) {
        var createReclamation = $A.get("e.force:createRecord");
        createReclamation.setParams({
            "entityApiName": "Reclamation__c",
            "defaultFieldValues": {
                "Contact__c": component.get("v.recordId")
            }
        });
        createReclamation.fire();
    }
})

*****************************************
ReclamationsListHelper.js

({
        fetchReclamations : function(component, event, helper) {
        var action = component.get("c.getReclamationList");
        var contactId = component.get("v.recordId");
        action.setParams({
            contactIds: contactId

        });

        action.setCallback(this, function(response) {
            var state = response.getState();
            if(state === 'SUCCESS') {

                var reclamationList = response.getReturnValue();

                component.set("v.contactList",reclamationList);
            }
            else {
                alert('Error in getting data');
            }
        });
        $A.enqueueAction(action);
        }    
})


*********

Thank you for your halp
Best Answer chosen by KARIM EL ALAOUI
Nayana KNayana K
component.set("v.contactList",reclamationList); line should be
changed to component.set("v.reclamationList",reclamationList);
hjv6606hjv6606 
Hello,

I am trying to accomplish the following:
  • Call an external REST API on Account page load
  • JSON response will be parsed into a table within a custom object
I have already coded the REST call in apex. How do I get this to interact with a custom object and run on page load? Do I need to use visualforce? I am having some trouble understaing how all of these elements interact, so any guidance would be helpful. Thanks!
Best Answer chosen by hjv6606
SRKSRK

no if you are using lightning 

then just create a lighitng componet 

 

<aura:component implements="flexipage:availableForAllPageTypes,force:hasRecordId" access="global" > 

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

</aura:component/>

in you JS file

({
    doInit: function(component, event, helper) {
        console.log(component.get("v.recordId"));
        helper.mymethod(component);
     },
})

helper

mymethod: function(component) 
    {
var action = component.get("c.GetAccountInfo");  // call your apex class method 
            action.setParams({
                AccountId : component.get("v.recordId") // pass the paramters 
            });
            action.setCallback(this, function(a) {
                           //handel the responce
                 }
$A.enqueueAction(action);

}

rima khanrima khan 
Hi!
I registered with trailhead.
I’m an SDR looking to expand my Salesforce skill set. Let’s pretend I have none. Particularly looking for the basics around reporting, and any other trails that may be beneficial to spend some time with.
My goal is to have a competent understanding of SF to build my sales as I enter a closing role and the relevant tools in SF that will help me gain an advantage.
Thanks in advance!
Best Answer chosen by rima khan
manasa udupimanasa udupi
Hi Rima,

Below are few trailhead links, hope it helps:)

https://trailhead.salesforce.com/en/content/learn/modules/sales_admin_sales_reports_for_lex
https://trailhead.salesforce.com/en/content/learn/modules/sales-activity-analysis
Jason CaldwellJason Caldwell 
I am trying to enable drag and drop functionality to the files component (related list-single) on various objects in lightning and have run into a bit of a snag... So far, this functionality works great provided there is *already* a file attached and listed in the component that I am trying to drag a new file onto.

However, in the situation where there are no currently attached files I am unable to drag and drop a new file. That being said though, if I click "Add files" and manually browse for the file I want it will upload and then I will be able to drag and drop any new files to that record from that point forward.

Image when record has zero attached files:
Zero FilesNote it just says "Move" - dropping the file here does nothing as far as I can tell.

Image where object has 1 or more attached files:

User-added imageNote that here it says "Move" but it also indicates that I can drop the file and doing so will immediately open the upload progress bar and complete the upload as expected.

Does anyone know what I'm doing wrong here? Or is this just a functionality oversight with lightning?
Best Answer chosen by Jason Caldwell
Jason CaldwellJason Caldwell
I contacted Salesforce Support and was told this is a known bug being tracked here: https://success.salesforce.com/issues_view?title=spring-20-drag-and-drop-not-available-on-files-or-attachments-related-lists&Id=a1p3A000001YoAz

Currently slated for the Spring 2020 release.
Parteek Goyal 3Parteek Goyal 3 

Hi All,

I want to know that why we use map instead of list in salesforce. Please help with scenario.

Thanks,
Parteek

Best Answer chosen by Parteek Goyal 3
Amit Chaudhary 8Amit Chaudhary 8
Please check below posy for same
1 ) http://amitsalesforce.blogspot.com/2016/09/collection-in-salesforce-example-using.html
2 ) http://www.salesforcegeneral.com/salesforce-articles/using-an-apex-map-with-a-list-of-sobjects.html

User-added image

Example 1:-  Using trigger populate the Account Field on the Contact record (only insert scenario)

If we use List and not Map
Apex Class
trigger ContactTriggerWithList on Contact (before insert) 
{
Set<Id> SetAccountId = new Set<Id>(); // Use set to collect unique account ID

for(Contact con: Trigger.new) 
{
 if(con.AccountId != null) 
 {
  SetAccountId.add(con.AccountId); // add Account in Set
 }
}

if( SetAccountId.size() >0 ) 
{
 List<Account> listAccount = [ Select Id, Name, Type from Account where Id IN :SetAccountId ]; // Query Related Account
 
 for(Contact con: Trigger.new) 
 {
  if(con.AccountId != null)
  {
   for(Account acc: listAccount)
   {
    if(con.AccountId == acc.Id)
    {
     con.Type__c = acc.Type;
    }
   }
  }
 }
} 
}


NOTE:- In this we are using List of Accounts, Where we have to loop through the matching Account every time to populate the Type__c in the second for loop. In this case need to use nested loop.
To Above the Nested Loop We can use the Map .

Same Trigger using the Map:
trigger ContactTriggerWithMap on Contact (before insert) 
{
    Set<Id> SetAccountId = new Set<Id>();
    for(Contact cont: Trigger.new) 
 {
        if(cont.AccountId != null) 
  {
            SetAccountId.add(cont.AccountId);
        }
    }
    
    if(SetAccountId.size() > 0 ) 
 {
        Map<Id, Account> mapAccount = new Map<Id, Account>([Select Id, Name, Type from Account where Id IN :SetAccountId ]);
        for(Contact cont: Trigger.new) 
  {
            if(cont.AccountId != null && mapAccount.containsKey(cont.AccountId) ) 
   {
                cont.Type__c = mapAccount.get(cont.AccountId).Type;
            }
        }
    }
}

NOTE:- Here we are using map of Account so we can directly use the Map to get the Account record. No need of 2nd for loop here
 
AniltAnilt 

Can any one please let me know when do we use list? when do we use map? when do we use set?

 

I'm bit confused regarding their usage.

Best Answer chosen by Admin (Salesforce Developers) 
HariDineshHariDinesh

Hi,

List,Set,Map are called collections in Apex:

List : A list is an ordered collection
so use list when you want to identify list element based on Index Number.(Lsit can contain Duplicates)
EX: List<account>

Set: A set is an unordered collection of primitives or sObjects that do not contain any duplicate elements.
So, use set if you want to make sure that your collection should not contain Duplicates.
EX: Set<account>

Map: A map is a collection of key-value pairs where each unique key maps to a single value. Keys can be any primitive data type, while values can be a primitive, sObject, collection type or an Apex object. For example, the following table represents a map of countries and currencies


Find below link for Detailed explanation regarding collections
http://www.salesforce.com/us/developer/docs/apexcode/Content/langCon_apex_collections.htm

 

:

 

Glenn Dailey 1Glenn Dailey 1 
The 'AccountProcessor' class did not achieve 100% code coverage via your test methods. Make sure that you chose 'Run All' tests in the Developer Console at least once before attempting to verify this challenge. I did the run all with no luck. I did notice that this is the new section that was just added and I ran into issues in the first unit too.

Create an Apex class with a method using the @future annotation that accepts a List of Account IDs and updates a custom field on the Account object with the number of contacts associated to the Account. Write unit tests that achieve 100% code coverage for the class.
Create a field on the Account object called 'Number_of_Contacts__c' of type Number. This field will hold the total number of Contacts for the Account.
Create an Apex class called 'AccountProcessor' that contains a 'countContacts' method that accepts a List of Account IDs. This method must use the @future annotation.
For each Account ID passed to the method, count the number of Contact records associated to it and update the 'Number_of_Contacts__c' field with this value.
Create an Apex test class called 'AccountProcessorTest'.
The unit tests must cover all lines of code included in the AccountProcessor class, resulting in 100% code coverage.
Run your test class at least once (via 'Run All' tests the Developer Console) before attempting to verify this challenge.

public class AccountProcessor
{
  @future
  public static void countContacts(Set<id> setId)
  {
      List<Account> lstAccount = [select id,Number_of_Contacts__c , (select id from contacts ) from account where id in :setId ];
      for( Account acc : lstAccount )
      {
          List<Contact> lstCont = acc.contacts ;
         
          acc.Number_of_Contacts__c = lstCont.size();
      }
      update lstAccount;
  }
}

and
@IsTest
public class AccountProcessorTest {
    public static testmethod void TestAccountProcessorTest(){
        Account a = new Account();
        a.Name = 'Test Account';
        Insert a;

        Contact cont = New Contact();
        cont.FirstName ='Bob';
        cont.LastName ='Masters';
        cont.AccountId = a.Id;
        Insert cont;
       
        set<Id> setAccId = new Set<ID>();
        setAccId.add(a.id);
 
        Test.startTest();
            AccountProcessor.countContacts(setAccId);
        Test.stopTest();
       
        Account ACC = [select Number_of_Contacts__c from Account where id = :a.id LIMIT 1];
        System.assertEquals ( Integer.valueOf(ACC.Number_of_Contacts__c) ,1);
  }
 
}
Best Answer chosen by Glenn Dailey 1
Amit Chaudhary 8Amit Chaudhary 8
I am glad that works. PLease mark best answer and close this thread so that if some one has same issue that post can help other
Kal KumarKal Kumar 
I am trying to understand why I cannot query the 'Notes' object directly, but can only use it via the Account relationship.

Below query does not work.
select CreatedBy.Name from Notes.

But this query works
select Name, (select CreatedBy.Name from Notes) from Account
Best Answer chosen by Kal Kumar
Khan AnasKhan Anas (Salesforce Developers) 
Hi Kal,

Greetings to you!

You need to use Note instead of Notes.
SELECT CreatedBy.Name FROM Note

In relationship queries, you need to use Child Relationship Name. Notes is the child relationship name. So, for Parent-Child relationship query you have to use below SOQL:
SELECT Name, (SELECT CreatedBy.Name FROM Notes) FROM Account

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas
Rosie HallRosie Hall 
I've made some changes to the Campaign page layout, primarily adding some quick actions.  This all works fine when logged in as admin.  However, when login as standard user page doesn't have these actions.
Both profiles have the same layout assigned (there is only one) and there is only one record type.
I've been in to the object settings for both profiles and are identical.
I've tried creating a the page layout from scratch and assigning but that doesn't work.
Any ideas what I am missing?
Best Answer chosen by Rosie Hall
Rosie HallRosie Hall
Worked out the issue - standard users didn't have Run Flows enabled in Profile permissions.
Lavanya Sanathkumar 44Lavanya Sanathkumar 44 
When I am trying to insert records to Salesforce using ARC(OAuth2) getting below error Error: This session could not be mutually authenticated for use with the REST API
{
"message": "This session could not be mutually authenticated for use with the REST API",
"errorCode": "MUTUAL_AUTHENTICATION_FAILED"
}

403 Forbidden

But this working fine before. I getting this error suddenly.

Can anyone help me with this?

Thanks in advance
Best Answer chosen by Lavanya Sanathkumar 44
Khan AnasKhan Anas (Salesforce Developers) 
Hi Lavanya,

Greetings to you!

This is a message from Salesforce that indicates that the password has expired or it is incorrect.

According to Salesforce doc, If a login call is made from the API for a user with an expired or temporary password, subsequent API calls to custom Apex REST Web service methods aren't supported and result in the MUTUAL_AUTHENTICATION_FAILED error. Reset the user's password and make a call with an unexpired password to be able to call Apex Web service methods.

Please change your password and check again.

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future.

Thanks and Regards,
Khan Anas