• Salim Mohamed
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 5
    Replies
Hello,
If I load a sObject array in init function, I m getting my array correctly filled and loaded to the UI using iteration. I create a new button to add (push) new element of the same type to the existing array. When I fill the value of ui:inputText and push the button to add a 2nd element, the first element is unbind (value is reset to empty) and so one upon element creation. For all elements loaded at the beginning the data are still binded and can be modified even after several add clicks.
<aura:component >
<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
<!--DATA MODEL: Test__c with only Name as text field-->
<aura:attribute name="alltests" type="Test__c[]" />

<aura:iteration items="{!v.alltests}" var="aTest" >
    <span>
        <ui:inputText  value="{!aTest.Name}"/>
    </span>
</aura:iteration>

<button  type="button"  onclick="{!c.add}">Add button</button>
</aura:component>

*******************************************
({
doInit : function(c, e, h) {
    var alltests = c.get("v.alltests");
    // Normally I load array from database data but fo the eample I only fill it with hard coded values
    alltests.push( {'sobjectType': 'Test__c', 'Name':'value 1'} );
    alltests.push( {'sobjectType': 'Test__c', 'Name':'value 2'} );
    alltests.push( {'sobjectType': 'Test__c', 'Name':'value 3'} );

    c.set("v.alltests", alltests);
},
/////////////////
 add : function(c, e, h) { // Hooked to new element button on UI
    var alltests = c.get("v.alltests");

    alltests.push( {'sobjectType': 'Test__c', 'Name':''} ); // Input is loaded blank and should be filled by user

    c.set("v.alltests", alltests);
}
//////////////////
})
User-added image
Step 1: Inputs loaded => OK Step 2: Push Add button then modification of values => OK Step 3: Modification of the 4th input(the new one) => OK Step 4: Push Add button => KO: values of new element is unbinded / erased

It drives me crazy because it's a basic use case.

Please help me it's quite urgent.

Thanks in advance
 
Hello,
If I load a sObject array in init function, I m getting my array correctly filled and loaded to the UI using iteration. I create a new button to add (push) new element of the same type to the existing array. When I fill the value of ui:inputText and push the button to add a 2nd element, the first element is unbind (value is reset to empty) and so one upon element creation. For all elements loaded at the beginning the data are still binded and can be modified even after several add clicks.
<aura:component >
<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
<!--DATA MODEL: Test__c with only Name as text field-->
<aura:attribute name="alltests" type="Test__c[]" />

<aura:iteration items="{!v.alltests}" var="aTest" >
    <span>
        <ui:inputText  value="{!aTest.Name}"/>
    </span>
</aura:iteration>

<button  type="button"  onclick="{!c.add}">Add button</button>
</aura:component>

*******************************************
({
doInit : function(c, e, h) {
    var alltests = c.get("v.alltests");
    // Normally I load array from database data but fo the eample I only fill it with hard coded values
    alltests.push( {'sobjectType': 'Test__c', 'Name':'value 1'} );
    alltests.push( {'sobjectType': 'Test__c', 'Name':'value 2'} );
    alltests.push( {'sobjectType': 'Test__c', 'Name':'value 3'} );

    c.set("v.alltests", alltests);
},
/////////////////
 add : function(c, e, h) { // Hooked to new element button on UI
    var alltests = c.get("v.alltests");

    alltests.push( {'sobjectType': 'Test__c', 'Name':''} ); // Input is loaded blank and should be filled by user

    c.set("v.alltests", alltests);
}
//////////////////
})
User-added image
Step 1: Inputs loaded => OK Step 2: Push Add button then modification of values => OK Step 3: Modification of the 4th input(the new one) => OK Step 4: Push Add button => KO: values of new element is unbinded / erased

It drives me crazy because it's a basic use case.

Please help me it's quite urgent.

Thanks in advance
 

Hi.

 

i have a trigger , when a team member is created ,automaically the team member goes and sits in group Member Object.

 

I am facing problem on after Update

 

Below is my code.

trigger createGroupMember on Team_member__c (after insert,after update) {
    set<Id> aIteamIds = new set<Id>();
    for(Team_member__c  tm : trigger.new){
        aIteamIds.add(tm.IATeam__c);
    }
    Map<String,Id> aIteamName = new Map<String,Id>();
    for(IA_Team__c ai : [select name,Public_Group_Name__c from IA_Team__c where Id IN: aIteamIds]){
        aIteamName.put(ai.Public_Group_Name__c,ai.Id);
    }
    Map<Id,Id> aIteamGroupId = new Map<Id,Id>();
    
    for(Group gp : [select Id,developerName from Group where developerName IN: aIteamName.keyset()]){
        if(aIteamName.containsKey(gp.developerName)){
            
            aIteamGroupId.put(aIteamName.get(gp.developerName),gp.Id);
        }        
    }
    List<GroupMember> newGroupMember = new List<GroupMember>();
    GroupMember gm;
    for(Team_member__c  tm : trigger.new){
       gm = new GroupMember();
       gm.GroupId = aIteamGroupId.get(tm.IATeam__c);
       gm.UserOrGroupId = tm.Team_member_Name__c;
       newGroupMember.add(gm);
    }
    if(newGroupMember.size()>0){
        insert newGroupMember;
    }

if(trigger.isupdate)
    {
        set<string> memname = new set<string>();
        Map<string,string> grpmem = New Map<string,string>();
        for(Team_member__c tm:Trigger.Old)
       {
            memname.add(tm.Team_member_Name__c);
            grpmem.put(tm.Team_member_Name__c,tm.Team_member_Name__c);
        }
    list<GroupMember> resultlist=new list<GroupMember>([select GroupId,UserOrGroupId from GroupMember where GroupId in:memname]);
        list<GroupMember> uplist=new list<GroupMember>();
        for (Integer i = 0; i < Trigger.new.size(); i++)
        {
            if(grpmem.containsKey(Trigger.old[i].Team_member_Name__c))
            {
               grpmem.put(Trigger.old[i].Team_member_Name__c,Trigger.New[i].Team_member_Name__c);
            }
        }
for (Integer i = 0; i < resultlist.size(); i++)
        {
            if(grpmem.containsKey(resultlist[i].UserOrGroupId))
            {
                resultlist[i].UserOrGroupId=grpmem.get(resultlist[i].Team_member_Name__c);
               //resultlist[i].UserOrGroupId=grpmem.get(resultlist[i].Team_member_Name__c);
                uplist.add(resultlist[i]);
            }
        }
        update uplist;
    }
}

 

Thanks in advance

  • September 14, 2013
  • Like
  • 0

I am using a custom controller(Not extension controller) for a VF page. That VF page has a lookup to Accounts. I want the selected lookup field value in my controller. I am using actionSupport for this(On change of lookup).

 

Any help?