+ Start a Discussion
Carrie Nunemaker 10Carrie Nunemaker 10 
I am completely new to Apex and could really use some help with what seems to be a simple task.  I have a formula on the contact, Persona_True__c, that returns a 1 if the custom field "persona" is populated and a 0 if it is blank.

I would like to have a roll-up summary that sums this field at the account level in a field called Related_Personas__c.  

Because we can't roll-up from contact to account I'm reading that this type of action needs to be a trigger, but I don't even know where to start.  Does anyone have any thoughts or expertise they can share to help me out? 
Best Answer chosen by Carrie Nunemaker 10
Anthony McDougaldAnthony McDougald
Good Evening Carrie,
Hope that your day is off to an amazing start. We've constructed a trigger to your specifications. Please test and report back if anything. Hope this helps and may God bless you abundantly.
trigger ContactSumTrigger on Contact (after delete, after insert, after undelete, after update) {

Contact[] cons;
    if (Trigger.isDelete){ 
    cons = Trigger.old;
    cons = Trigger.new;
Set<ID> acctIds = new Set<ID>();
for (Contact con : cons) {

Map<ID, Contact> contactsForAccounts = new Map<ID, Contact>([SELECT Id, AccountId, Persona_True__c FROM Contact WHERE AccountId IN :acctIds]);

Map<ID, Account> acctsToUpdate = new Map<ID, Account>([SELECT Id, Related_Personas__c FROM Account WHERE Id IN :acctIds]);

for (Account acct : acctsToUpdate.values()) {
Set<Id> conIds = new Set<Id>();
Decimal totalValue = 0;
for (Contact con : contactsForAccounts.values()) {
    if (con.AccountId == acct.Id && con.Persona_True__c != NULL) {
        totalValue += con.Persona_True__c; 
acct.Related_Personas__c = totalValue;
if(acctsToUpdate.values().size() > 0) {
    update acctsToUpdate.values();

Best Regards,
Anthony McDougald

I have a list I need to sort by a primary key as well as a secondary key - I tried ORDER BY fieldName AND fieldNAME as well as ORDER BY fieldName AND BY fieldName - neither one compiled on save. 


Any ideas? 





Best Answer chosen by Admin (Salesforce Developers) 

Order By fieldName1, fieldName2

Best Answer chosen by Pierce Hale 15
vijay kumar kvijay kumar k
Hi Pierce

Greetings to you,

All content document public links are got stored in ContentDistribution Object.
For object reference: https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_contentdistribution.htm
Yes pierce, you can query public url from content distribution object with help of ContentDocumentID or ContentVersionId.

Ex : Select Id,ContentDocumentId,ContentDownloadUrl,DistributionPublicUrl from ContentDistribution where ContentDocumentId='0691000000FOq3nAAD'

I hope this is helpful to you. Please mark this as the best answer if it's useful to you.

Agnibha Chakrabarti 10Agnibha Chakrabarti 10 
I have to replicate the New Case to create a new case in lightning component. I have to create look up input box in that page.
and Store the value in case object after clicking the Save button.

Can anybody help me with the creation of lookup input field and storing it into the Case object?

Best Answer chosen by Agnibha Chakrabarti 10
Devi ChandrikaDevi Chandrika (Salesforce Developers) 

To create lookup input field in lightning we have to create custom lightning component.
Please refer below links which might help you with this

Here is an idea to vote on this

Hope this helps you
If this helps kindly mark it as solved so that it may help others in future.

Thanks and Regards

YiQin HeYiQin He 

I created a lightning component as a quick action button. In the component, I have a cancel button that I want it closed when user clicks.
User-added image

But the problem is that I cannot find any document explain how to close the modal dialog. This is the ui code:
<aura:component controller="ContactController" implements="force:lightningQuickActionWithoutHeader,force:hasRecordId" >
        .changeRecordTypeRow {
        margin-top: 1.5rem;
        margin-bottom: 0;
        margin-left: 0;
        margin-right: 0;
        .changeRecordTypeLeftColumn {
        float: left;
        text-align: right;
        padding-right: 1.5rem;
        width: 35%;
        font-size: .8125rem;
        color: rgb(84, 105, 141);
        .changeRecordTypeRightColumn {
        float: right;
        text-align: left;
        width: 65%;
        	height:auto !important;
        .forceChatterLightningComponent .bodyWrapper{height:100%;width:100%;padding:0;box-sizing:border-box}
    <div class="modal-header slds-modal__header">
        <h2 class="title slds-text-heading--medium" >Change Contact Type</h2>
    <div class="scrollable slds-modal__content slds-p-around--medium">
        <div class="changeRecordTypeRow">
            <fieldset class="slds-form-element">
                <div class="changeRecordTypeLeftColumn">
                    <legend class="form-element__legend slds-form-element__label">Select a record type</legend>
                <div class="changeRecordTypeRightColumn slds-form-element__control">

                    <span class="slds-radio">
                        <input type="radio" id="radio_PrimaryContact" name="recordType" />
                        <label class="slds-radio__label" for="radio_PrimaryContact">
                            <span class="slds-radio--faux"></span>
                            <span class="slds-form-element__label">Primary Contact</span>
                    <span class="slds-radio">
                        <input type="radio" id="radio_SecondaryContact" name="recordType" />
                        <label class="slds-radio__label" for="radio_SecondaryContact">
                            <span class="slds-radio--faux"></span>
                            <span class="slds-form-element__label">Secondary Contact</span>
    <div class="modal-footer slds-modal__footer">
    	<div class="forceChangeRecordTypeFooter">
        	<button type="button" class="slds-button slds-button--neutral .slds-modal__close" aura:id="btnCancel" >
            <button type="button" class="slds-button slds-button--brand" aura:id="btnSave">
Does anyone have similar experience? Thanks in advance.
Best Answer chosen by YiQin He
YiQin HeYiQin He
Hi Karthik,

Thanks for the reply. I've already found the solution.
Call this method $A.get("e.force:closeQuickAction").fire() will close the modal dialog.


I alwaays get error when i try to save something from Dev console

Failed to create createContainerMember for containerId duplicate value found: <unknown> duplicates value on record with id: <unknown>
Best Answer chosen by Sandrine

Follow these stepsGo to Developer Console -> Work Space -> New Workspace
Create a new workspace
Save classes/triggers


Try again, it should be fixedIf my answer helps resolve your query, please mark it as the 'Best Answer' and upvote it to benefit others and improve the overall quality of Discussion Forums.

Ashlekh Gera


Hello Helper


I want to export   from an org a package  containing  custom objects,  Custom fields , classes,  custom buttons......


I created a package.xml  file where I included  the Metadata  types  I want to export


I can not  specify  Custom button Metadata  type

Looking into the salesforce docs it seems to me that is is  considered as weblink


I tried  something like  below







but it does not work


any suggestion?



Thanks in advance






Best Answer chosen by csbaa
David CheungDavid Cheung
@csaba, meta data name for custom button is WebLink - in the singular form, you had it as WebLinks.
@Admin why was @Vinita_SFDC chosen as the best answer?

I got following error on step 3.

Challenge Not yet complete... here's what's wrong: 
Couldn’t find Agency records from the Account object.

Can anyone pass this step?
Thanks in advance.

Best Answer chosen by LinThaw
Hi Jennifer and ankita,

Please refer below, I passed this step 3.

fig 1.
User-added image

fig 2.
User-added image

and create Top 5 Agencies lenses.

Justin DurossJustin Duross 
Hello, for the Salesforce Trailhead "Using Future Methods" I keep getting the error "The 'AccountProcessorTest' test class doesn't appear to be calling the 'AccountProcessor.countContacts' method between Test.startTest() and Test.stopTest()." I believe I have the right syntax, so I'm not sure what is wrong. My main class is fine. the problem only seems to be in the AccountProcessorTest.apxc

@isTest private class AccountProcessorTest {
    @isTest static void countContacts() {
        Test.setMock(AccountProcessorTest.class, new Account());

Here is my main class in case anyone needs it:

global class AccountProcessor {
    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;

Thank you in advance!
Justin Duross

Best Answer chosen by Justin Duross
Amit Chaudhary 8Amit Chaudhary 8
Please check below post for same issue
1) https://developer.salesforce.com/forums/?id=906F0000000D8hwIAC

Please update your Test class like below:-
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>();
        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);
Let us know if this will help you

Jordan MJordan M 
I am new to LWC and cant seem to figure out how to open the source code for LWC. Aura can be opened in the dev console but from what i understand this is not possible with LWC.

Is it possible to open a LWC source code from within the org? I have a LWC that was developed by someone else that needs editing. How can I access the source code?
Best Answer chosen by Jordan M
Soyab HussainSoyab Hussain
Hi Jordan Mathews,

Step 1. Go to workbench and login.


Step 2.  Click on retrieve button.

User-added image
Step 3. click on "Choose File" button and upload package.xml file.

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">

Step 4. click on next and retrieve metadata, it will give you all the LWC components exist in your org.

User-added image

Step 5. click Download ZIP File.