You need to sign in to do that
Don't have an account?
Fred13
Getting Field Values from Variable in Lightning Controller
I am trying to build a page to clone a record. I have the page and I am able to pass the current record to the new component in an attribute but I'm really struggling to figure out how I can take the values from that one record and populate x number of dummy records with the values. I am new to javascript.
What I have so far is the variable "CloneGS" which does get populated with the record. I was trying to loop through x number of times (eventually, that number will also get passed from the original component) and then add a record to my attribute, "newgroupstructures" and then display these on the page so they can be edited and then created.
Any help would be greatly appreciated!!!! thanks!!! Fred
Here is my component:
What I have so far is the variable "CloneGS" which does get populated with the record. I was trying to loop through x number of times (eventually, that number will also get passed from the original component) and then add a record to my attribute, "newgroupstructures" and then display these on the page so they can be edited and then created.
Any help would be greatly appreciated!!!! thanks!!! Fred
Here is my component:
<!-- here is the variable to hold thegroup structure that gets passed from the GroupStructures Component (that was clicked) --> <aura:attribute name="existinggroupstructure" type="Group_Structure__c" /> <aura:attribute name="newGroupStructures" type="Group_Structure__c[]"/> <!-- Handle component initialization in a client-side controller --> <aura:handler name="init" value="{!this}" action="{!c.doInit}"/> <!-- <aura:handler event="c:GSCloneRecords" action="{!c.createGS}" /> --> <aura:iteration items="{!v.newGroupStructures}" var="gs"> <p>{!gs}</p> </aura:iteration>Here is my controller:
Here is my doInit controller: doInit : function(component, event, helper) { //variable for the record that we are cloning from the component var CloneGS = component.get("v.existinggroupstructure"); //variable to hold the new records var gs = []; //Loop through and create 5 rows with same field data in the for(var i = 0;i < 5;i++){ // doesnt work.... gs.push({'Name':'Test'+i, 'Group_Number__c': testfield}); gs.push({'Name' : 'Test'+i}); } component.set("v.newGroupStructures",gs); },
All Answers
I want to take the field values populated in this variable var CloneGS = component.get("v.existinggroupstructure");
and into the v.numbers attribute?
thanks!!!!
Fred
<aura:attribute name="newGroupStructures" type="List"/>
<aura:iteration var="TempGS" items="{!v.newGroupStructures}">
{!TempGS.value}
{!TempGS.name.value}
{!TempGS.Section_Code__c.value}
</aura:iteration>
But my values on the page are:
name: 0 Section_Code__c: 0099
name: 1 Section_Code__c: 0099
etc
How do I now use this in a edit form that I can then create new records from? thanks again!!!
Fred