• Louis Nguyen
  • NEWBIE
  • 35 Points
  • Member since 2015
  • Data Architect
  • Young Presidents Organization


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 3
    Replies
Hello Everyone,
The code snippet works for the limited data sample.  I want to bulkify the part where it updates the spousename.

This SF article said I can use a MAP variable.    
https://developer.salesforce.com/page/Programming_Techniques#Using_a_Map_as_an_In-Memory_Join_Table

I am struggling at what to do.  Please help me write the Map and Map.put statements.  Thanks.

 
//get the Scotland Members 
Relationship__c[] MemberIDs=[
	SELECT Account__c,contact__c
	FROM Relationship__c
	WHERE relationship_type__c='member'
	and Contact__c in (
		SELECT Contact__c
		FROM Account_Affiliation__c
		WHERE Account__c='0016100000STADyAAP'
		and Benefit_Status__c not in ('Terminated')
		and IsActive__c = true
		and IsDeleted = false)
];

//instantiate the report object variable
list<RptChapterRoster__c> rptList = new list<RptChapterRoster__c>();

//create the rpt rows
for(Relationship__c r :MemberIDs){
        rptList.add(new RptChapterRoster__c(Chapter_Name__c='WPO Scotland',Member_Contact__c = r.contact__c,Household_Account__c=r.account__c ));
}

//update with spousename -- this is not bulkified -- can't figure out how to use map for this
for(RptChapterRoster__c myvar:rptList) {
	Relationship__c  r = [select id,contact__c from Relationship__c where relationship_type__c='spouse' and account__c = :myvar.household_account__c];
	myvar.Spouse_Contact__c=r.contact__c;
}

insert rptList;


 
Hello Everyone,
If you are a YPO Management Team Member and are going through the Trailhead training, please reply to this email thread.  Thanks!
Hi,
I keep getting this error when trying to do a Trailhead Challenge.  Any ideas?  Thanks.
User-added image

Here is my code:
PhoneNumberEvent.evt
<aura:event type="APPLICATION" description="Event template">
    <aura:attribute name="phone" type="String"/>
</aura:event>
MyApplication.app
<aura:application >
    ({
	send : function(component, event, helper) {
		var phone = component.find("phone").get("v.value");
        console.log(phone);
        $A.get("event.c:PhoneNumberEvent").setParams({
            phone: phone
       }).fire();
	}
	})
    
    ({
	answer : function(component, event, helper) {
		var text = event.getParam("phone");
        component.set("v.phone", text);
	}
	})

    <c:PhoneNumberInput/>
    <c:PhoneNumberOutput/>
</aura:application>
PhoneNumberInput.cmp
<aura:component >
    <aura:registerEvent name="PhoneNumberEvent" type="c:PhoneNumberEvent"/>
    <ui:inputPhone aura:id="phone" label="phone" />
    <ui:button label="Show Phone" press="{!c.send}"/>
</aura:component>
PhoneNumberOutput.cmp
<aura:component >
    <aura:attribute name="phone" type="String" default="No Phone Number"/>
    <ui:outputText aura:id="phone" value="{!v.phone}"/>
    <aura:handler event="c:PhoneNumberEvent" action="{!c.answer}"/>
</aura:component>
Hello Everyone,
The code snippet works for the limited data sample.  I want to bulkify the part where it updates the spousename.

This SF article said I can use a MAP variable.    
https://developer.salesforce.com/page/Programming_Techniques#Using_a_Map_as_an_In-Memory_Join_Table

I am struggling at what to do.  Please help me write the Map and Map.put statements.  Thanks.

 
//get the Scotland Members 
Relationship__c[] MemberIDs=[
	SELECT Account__c,contact__c
	FROM Relationship__c
	WHERE relationship_type__c='member'
	and Contact__c in (
		SELECT Contact__c
		FROM Account_Affiliation__c
		WHERE Account__c='0016100000STADyAAP'
		and Benefit_Status__c not in ('Terminated')
		and IsActive__c = true
		and IsDeleted = false)
];

//instantiate the report object variable
list<RptChapterRoster__c> rptList = new list<RptChapterRoster__c>();

//create the rpt rows
for(Relationship__c r :MemberIDs){
        rptList.add(new RptChapterRoster__c(Chapter_Name__c='WPO Scotland',Member_Contact__c = r.contact__c,Household_Account__c=r.account__c ));
}

//update with spousename -- this is not bulkified -- can't figure out how to use map for this
for(RptChapterRoster__c myvar:rptList) {
	Relationship__c  r = [select id,contact__c from Relationship__c where relationship_type__c='spouse' and account__c = :myvar.household_account__c];
	myvar.Spouse_Contact__c=r.contact__c;
}

insert rptList;


 
Hi,
I keep getting this error when trying to do a Trailhead Challenge.  Any ideas?  Thanks.
User-added image

Here is my code:
PhoneNumberEvent.evt
<aura:event type="APPLICATION" description="Event template">
    <aura:attribute name="phone" type="String"/>
</aura:event>
MyApplication.app
<aura:application >
    ({
	send : function(component, event, helper) {
		var phone = component.find("phone").get("v.value");
        console.log(phone);
        $A.get("event.c:PhoneNumberEvent").setParams({
            phone: phone
       }).fire();
	}
	})
    
    ({
	answer : function(component, event, helper) {
		var text = event.getParam("phone");
        component.set("v.phone", text);
	}
	})

    <c:PhoneNumberInput/>
    <c:PhoneNumberOutput/>
</aura:application>
PhoneNumberInput.cmp
<aura:component >
    <aura:registerEvent name="PhoneNumberEvent" type="c:PhoneNumberEvent"/>
    <ui:inputPhone aura:id="phone" label="phone" />
    <ui:button label="Show Phone" press="{!c.send}"/>
</aura:component>
PhoneNumberOutput.cmp
<aura:component >
    <aura:attribute name="phone" type="String" default="No Phone Number"/>
    <ui:outputText aura:id="phone" value="{!v.phone}"/>
    <aura:handler event="c:PhoneNumberEvent" action="{!c.answer}"/>
</aura:component>