• Fred13
  • NEWBIE
  • 100 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 1
    Likes Given
  • 29
    Questions
  • 47
    Replies
I have completed this Trail but when I add the map to the AllowLocator component, I receive an error, "Uncaught Action failed: c:AccountMap$controller$onAccountsLoaded [Cannot read property 'length' of null]
Callback failed: apex://AccountSearchController/ACTION$searchAccounts"

Any help would be greatly appreciated!!
  • March 23, 2020
  • Like
  • 0

I have turned on "Associate a Contact with Multiple Accounts".  I use a visualforce page to display my accounts and I'm trying to figure out the name of the related list to use.  

I used AccountContactRoles but I'm not getting the right page layout or buttons as expected.  thanks!!! 
 

Fred

  • February 20, 2019
  • Like
  • 0
I have been working on this for quite a while without success. I posted this previously but did not get an answer.  I open a secnd component to add some records and when I save, I navigate back to the original component.  THe problem is that the newly created records do not display on the original component.  The odd thing is that the doint function does not fire when I navigate back. Therefore, my assumption is that the first component never closes when I navigate to the second component to create the records.  Please help!!!!! Trying to either close the first component out when I navigate to the second or refresh the first when I go back.  Here is the code on the second componet to save record and navigate back to first component.  thanks!!!!

Fred
 
insertGS : function(component, groupstructures, callback) {
 
		//call apex to save the newly created group structures
  		var action = component.get("c.saveGroupStructure");
        	action.setParams({gs: groupstructures
	        });
    
  $A.enqueueAction(action);
          
  ///This part of code is used to navigate back to the GroupStructuresList Component
        //variable to hold the account id for my naviagation back to original component
        var recordId = component.get("v.existinggroupstructure.Account__c")
        //set urlEvent Variable to navigate back to the original component
         var urlEvent = $A.get("e.force:navigateToURL");
        urlEvent.setParams({
            "url" : "lightning/n/Group_Structures_List?//Aid=" + recordId + "&Tid=123456789"    
        });
        ///navigate back to groupstructures page
        urlEvent.fire();

      
        },

 
  • December 10, 2018
  • Like
  • 1
I have a lightning component that calls a second lightning component to clone records.  After I am done on this second component, I want to navigate back to the original and refresh it so it includes the new records.  I am able to return back to the original lightning component but the newly created records are not displaying unless I click refresh on browser.  How can I navigate and refresh?  THis is how I am returning to my original component on save:
 
createClones: function(component, GroupStructures) {
    //Save the expense and update the view
    console.log('### Im in the first function ' );
    this.upsertGS(component, GroupStructures, function(a) {
        //var groupstructures = component.get("v.newGroupStructures");
        GroupStructures.push(a.getReturnValue());
        component.set("v.newGroupStructures", GroupStructures);
    });
  },
    
    upsertGS : function(component, groupstructures, callback) {
        //variable to hold the account id for my naviagation back to original component
        var recordId = component.get("v.existinggroupstructure.Account__c")
        //set urlEvent Variable to navigate back to the original component
        var urlEvent = $A.get("e.force:navigateToURL");
        urlEvent.setParams({
            "url" : "lightning/n/Group_Structures_List?//Aid=" + recordId + "&Tid=123456789"    
        });
		//call apex to save the newly created group structures
  		var action = component.get("c.saveGroupStructure");
        	action.setParams({ 
          	gs: groupstructures
	  });
  if (callback) {
      action.setCallback(this, callback);
  }
        
  $A.enqueueAction(action);
        ///navigate back to groupstructures page
        urlEvent.fire();
},



Thanks!!

Fred
  • December 04, 2018
  • Like
  • 0
Hi.  I actually have two quesitons.  First, is the following a list or array?

var gs = []

Second, how do I determine the size of that variable?  console.log(gs.size()); renders an error

Finally, how do I determine the size of an attribute for a custom oject.  For example, I have the following attribute on my component:

<aura:attribute name="newGroupStructures" type="Group_Structure__c[]"/>

How can I write a console.log to see the size of that?

thanks!!!!

Fred
  • November 28, 2018
  • Like
  • 0
Hi.  I have been working on a cloning process that allows me to copy a record x number of times and then saving those copies as new records.

I am stuck on saving the records and returning to the original component.

I have the records saved in an attribute on the javascript controller but they are not getting passed to the controller  I suspect that my syntax is off or that I cannot pass multiple values.  So I have two problems that I'm asking for help with:
1. why am I getting a null pointer error on my apex class (the variable I'm passing to the apex class is not getting populated)
2. How can I pass the account ID back to my component (GroupStructures) so I can navigate back here after the save.

Any help would be greatly appreciated!!!

Here is the Component and Apex Class
({
	createClones: function(component, GroupStructures) {
    //Save the expense and update the view
    this.upsertGS(component, GroupStructures, function(a) {
        var groupstructures = component.get("v.newGroupStructures");
        groupstructures.push(a.getReturnValue());
        component.set("v.newGroupStructures", groupstructures);
    });
},
    
    upsertGS : function(component, GroupStructures, callback) {
        //set the return page
      	var evt = $A.get("e.force:navigateToComponent");
		evt.setParams({
            componentDef: "c:GroupStructures",
            componentAttributes :{ 
              recordId:groupstructure.Account__c
             }
        });
  var action = component.get("c.saveGroupStructure");
	  action.setParams({ 
          //I have confirmed that the values are in my variable in the js controller
      group_structure__c: GroupStructures
	  });
  if (callback) {
      action.setCallback(this, callback);
  }
  $A.enqueueAction(action);
        ///navigate back to groupstructures page
        evt.fire();
},
public class GSClone {
	@AuraEnabled

	public static group_structure__c saveGroupStructure (group_structure__c gs) {
    //public static group_structure__c saveGroupStructure (groupstructure gs) {
	system.debug ('### I got in the apex class' + gs);

	insert gs;
	return gs;
    
    }
}




 
  • November 26, 2018
  • Like
  • 0
I want to use a child component for each record and iterate over it on the main component.  For some reason, the values don't show when I try to use this approach.

If I simply iterate and use the recordEditForm it works fine.  However, once I try to use the second component the values do not show.  Here is my iteration from the primary component:
 
<aura:iteration var="groupstructure" items="{!v.newGroupStructures}">
                  <c:GSCloneRecord groupstructure="{!groupstructure}"/>
            </aura:iteration>

Here is the GSCloneRecord Component.  I am unsure of  how to reference the values in teh groupstructure attribute.  I tried adding value= but that did not seem to work.  Any help would be greatly appreciated!!! thanks!!!!
 
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,force:hasRecordId,lightning:isUrlAddressable" controller="GSController">
    <aura:attribute name="groupstructure" type="Group_Structure__c" />
	<!-- Handle component initialization in a client-side controller -->
	<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>

    <lightning:recordEditForm
             
            objectApiName="Group_Structure__c">
            <!-- the messages component is for error messages -->
            <lightning:messages />
  <lightning:layout multipleRows="true" verticalAlign="center" >
      <lightning:layoutItem size="1" padding="around-Small" >
 						<lightning:inputField aura:id="Name" fieldName="Name"   />
      				</lightning:layoutItem>

      
      
      <lightning:layoutItem size="1" padding="around-Small" >
 		<lightning:inputField fieldName="Status__c"/>
      </lightning:layoutItem>
      
     <lightning:layoutItem size="2" padding="around-Small">
        <lightning:inputField fieldName="Funding_Type__c"/>
     </lightning:layoutItem>
      <lightning:layoutItem size="1" padding="around-Small" class="customRequired">
    <lightning:inputField fieldName="Group_Number__c"/>
     </lightning:layoutItem>
    <lightning:layoutItem size="1" padding="around-Small" class="customRequired">
    <lightning:inputField fieldName="Section_Code__c"/>
     </lightning:layoutItem>
      <lightning:layoutItem size="1" padding="around-Small" class="customRequired">
       <div class="LSELabel">
        <lightning:inputField fieldName="Package_Code__c" />
      </div>
    </lightning:layoutItem>
    <lightning:layoutItem size="2" padding="around-Small" class="customDates">
        <lightning:inputField fieldName="Effective_Date__c"/>
    </lightning:layoutItem>
    <lightning:layoutItem size="2" padding="around-Small" class="customDates">
        <lightning:inputField fieldName="End_Date__c"/>
    </lightning:layoutItem>
      <lightning:layoutItem size="1" padding="around-Small" class="customProds">
        <lightning:inputField fieldName="Health_Product__c"/>
    </lightning:layoutItem>
    <lightning:layoutItem size=".5" padding="around-Small" class="customProds">
        <lightning:inputField fieldName="Prescription__c" />
    </lightning:layoutItem>
    <lightning:layoutItem size=".5" padding="around-Small" class="customProds">
      <lightning:inputField fieldName="Dental__c"/>
    </lightning:layoutItem>
    <lightning:layoutItem size=".5" padding="around-Small" class="customProds">
      <lightning:inputField fieldName="Vision__c"/>
    </lightning:layoutItem>
    <lightning:layoutItem size="1" padding="around-Small" class="customProds">
      <lightning:inputField fieldName="CDH_Status__c"/>
    </lightning:layoutItem>
    <lightning:layoutItem size="1" padding="around-Small" class="customRating">
      <lightning:inputField fieldName="Rating_Category__c"/>
    </lightning:layoutItem>
    <lightning:layoutItem size="3" padding="around-Small" class="customRating">
      <lightning:inputField fieldName="Coverage_Categories__c"/>
    </lightning:layoutItem>
    <lightning:layoutItem size="1" padding="around-Small">
      <lightning:inputField fieldName="Prefix__c"/>
    </lightning:layoutItem>
      <lightning:layoutItem size="5" padding="around-Small">
        <lightning:inputField fieldName="Description__c"/>
    </lightning:layoutItem>
        </lightning:layout>
        </lightning:recordEditForm>

</aura:component>



 
  • November 20, 2018
  • Like
  • 0
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:
 
  
<!-- 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);
  },


 
  • October 26, 2018
  • Like
  • 0
I have a component where I am receiving the value of a record from another component (they click a button next to the row which opens the second component)  That component that contains the record is existinggroupstructure.

I want to take the values from the fields in that attribute and display them in multiple rows so the user can change the values and save the records and populate this attribute:

<aura:attribute name="newGroupStructures" type="Group_Structure__c[]"/>
Essentially, cloning the record that is in the existinggroupstructure attribute.

I'm just stuck on the controller to populate the list and the component (what to use) to display the new records.

Any help would be greatly appreciated!!

Fred


 
  • October 24, 2018
  • Like
  • 0
I have a component that display a listing of records.  When clicking a button on that list, I am opening a second component.   The first component will pass data to the first component to clone the record.  What is the best way to do this?  I think that I would need to use an event but then I saw some posts (that I could not fully understand) that talked about the concept of parent and child components.

I'm just trying to find the best way to open the second component and pre-populate values.  The record will be saved and the user should be directed back to the original component.

thanks!!

Fred
  • October 23, 2018
  • Like
  • 0
Can anyone advise how I can get variable from a url and store them as attributes that I can use to filter data?  Here is my current url:

lightning/n/Group_Structures_List?Aid=001q000000nv4YT&Tid=001q000000nv52W

I need to understand how I create two different variables... Aid should hold the id that follows the and Tid should hold the id that follows.

Thank you!!

Fred
  • October 16, 2018
  • Like
  • 0
I am trying to understand how I code my controller to handle multiple fields on a component used to sort my list.  I have 6 lightning:select fields on my component that I want to use to filter down my list attribute.  I'm using this for one of the fields (which works fine)  However, I'm struggling how to further filter the "filter" list so that it removes any that don't meet the other field criteria.  Any help is greatly appreciated!!!!!!

thanks!!!
Fred
if(selectedGroupNum != '' && selectedGroupNum != "All") {
                 if(c.Group_Number__c == selectedGroupNum){
                           filter[k] = c;
                     //console.log('!!! 2 filter' + JSON.stringify(filter[k]));
                            k++; 
                  }
             }

//Set the filtered list of contacts based on the selected option
         component.set("v.groupstructures", filter);
  • October 10, 2018
  • Like
  • 0
Is there a way that I can actually see the contents of the variable I create rather than just object?  In sample below, I am printing to the console log the value of the components v.groupstructureList... but when I look at the console in chrome, I just see object and not the actual values? thanks!!!

Fred

User-added image
  • October 04, 2018
  • Like
  • 0
I have a list of strings that I want to display on my component.  The issue I am currently having is actually displaying the values in the attribute.

My attribute is: <aura:attribute name="groupnumbers" type="group_structure__c[]" />

My select field is: 
<lightning:layoutItem padding="around-small">
            <!-- Create a dropdown menu with options for Section code-->
            <lightning:select aura:id="selectGroupNum" label="GroupNum" name="sourceGroupNum" onchange="{!c.handleSelect}">
          			 <aura:iteration items="{!v.groupnumbers}" var="gs">
            		<option value="{!gs}">{!gs.label}</option>
        		 </aura:iteration>
            </lightning:select>
     	 </lightning:layoutItem>

I am certain that my option value is the issue.  How do I display the attribute when it is just a list of strings?  Also, can I set a default?

Thank you!!!!

Fred
  • October 02, 2018
  • Like
  • 0
I have a component with a few Lightning:Select fields that I'm using to filter the page.  I am populating the values using an apex class to pull the values for all existing records.  See below for snipet of the apex class.  
 
//get a deduped list of group numbers 
 @AuraEnabled 
    public static List<group_structure__c> getgroupnumbers() {
        List<group_structure__c> groupstructures = 
                [SELECT Id, group_number__c FROM group_structure__c];
  
        //added to pull in group numbers
        List<group_structure__c> groupnumbers = new List<group_structure__c>();
        
        Set<String> fgroupnumbers = New Set<String>();
        
        for (group_structure__c gs : groupstructures){
		      if (fgroupnumbers.Contains(gs.group_number__c) == FALSE){
	              fgroupnumbers.add(gs.group_number__c);
	              groupnumbers.add(gs);
              }
            groupnumbers.add('all');
            system.debug('group numbers' + groupnumbers);
        }
        return groupnumbers;
    }
I'm trying to add a value of "All" which would be the default value.  In my client side controller I will then filter the overall list based on these values.  I can't figure out how to add an "All" value.  I tried to just add it in the component, however, no value gets associated to selected All when using this method (see below)
<lightning:layoutItem padding="around-small">
            <!-- Create a dropdown menu with options for Group Number-->
            <lightning:select aura:id="selectGroupNum" label="GroupNum" name="sourceGroupNum" onchange="{!c.handleSelect}">
                 <option value="">All</option>
       			 <aura:iteration items="{!v.groupnumbers}" var="gs">
            		<option value="{!gs.id}">{!gs.Group_Number__c}</option>
        		 </aura:iteration>
            </lightning:select>
     	 </lightning:layoutItem>
Any help would be greatly appreciated!!!
Thanks!!

Fred
 
  • October 01, 2018
  • Like
  • 0
I'm trying to display a select list of values from a field on one of my attributes.  I have been able to display them, however, I was wondering if there was an easy way to eliminate the duplicates.  

The attribute is  <aura:attribute name="groupstructures" type="Group_Structure__c[]"/>

The section of code for the selection is
 
<lightning:layoutItem padding="horizontal-medium" size="4">
            <!-- TEST Create a dropdown menu with options for Section code-->
            <lightning:select aura:id="selectSection" label="Section" name="sourceSection" >
       			 <aura:iteration items="{!v.groupstructures}" var="gs">
            		<option value="{!gs.id}">{!gs.Section_Code__c}</option>
        		 </aura:iteration>
            </lightning:select>
</lightning:layoutItem>


 
  • September 27, 2018
  • Like
  • 0
I am wondering if there is a way to view a variables contents in the console in chrome?  I am using the following line of code in my controller:

console.log('here is group structure list' + component.get("v.groupstructureList"));

When I look at the results in the console, I only see:

here is group structure list[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]

Is there a way to see the real contents of the variable?

thanks!!

Fred
  • September 25, 2018
  • Like
  • 0
Hi.  I am trying to build a component that has several select fields where the user can filter down the list of records that were returned.  On the component I have three select fields.  Here is an example of one of those fields:

           <lightning:layoutItem padding="horizontal-medium" size="4">
            <!-- Create a dropdown menu with options for Status-->
            <lightning:select aura:id="selectStatus" label="Status" name="sourceHP" 
                              onchange="{!c.handleSelect}" class="slds-m-bottom_small">
                 <option value="">-- Select a Status --</option>
                <option value="All" text="All"/>
                <option value="Draft" text="Draft"/>
                <option value="Final" text="Final"/>
            </lightning:select>
     </lightning:layoutItem>

In the controller I am trying to figure out the best way to updte the list to apply the filters.  Right now, this is what I have.  Its certainly not ideal as I add more select fields the code will become unmanageable.  Looking for help on the best way to refactor the code to account for several filters.

Here is the Controller:
   handleSelect : function(component, event, helper) {
        var groupstructures = component.get("v.groupstructures");
  //The groupstructureList is getting populated correctly in the below line of code
        var groupstructureList = component.get("v.groupstructureList");
          var selectedActive = component.find("select").get('v.value');
          var selectedHP = component.find("selectHP").get('v.value');
          var selectedStatus = component.find("selectstatus").get('v.value')
        var filter = [];
        var k = 0;
        for (var i=0; i<groupstructureList.length; i++){
            var c = groupstructureList[i];
              if (selectedActive == "All" && selectedHP == "All"){
                  filter = groupstructureList
              }
            else if (selectedActive != "All" && selectedHP == "All"){
                     if(c.Active__c == selectedActive){
                           filter[k] = c;
                            k++; 
                    }
            }
             else if (selectedActive == "All" && selectedHP != "All"){
                     if(c.Health_Product__c == selectedHP){
                           filter[k] = c;
                            k++; 
                    }
            }
            else if (selectedActive != "All" && selectedHP != "All"){
                     if(c.Health_Product__c == selectedHP && c.Active__c == selectedActive){
                           filter[k] = c;
                            k++; 
                    }
            }
         }
      
   
        //Set the filtered list of contacts based on the selected option
        component.set("v.groupstructures", filter);
        helper.updateTotal(component);
        console.log(component.find("select").get('v.value'));

    }

And one more question, can I create a select list that dynamically contains values based on the current list.  For example, the current list of group structures may have a total of 3 unique values in the "Section__c" field  I want a select list to show just those options so the user can filter that field if needed.  That field holds a 4 digit number so it would be impossible for me to pre-populate the values.

Thank you!!!!

Fred
  • September 21, 2018
  • Like
  • 0
Hi.  I am very new to lightning development.  Is there a way to:
1. extend my select option fields so they display in more than just one column?
2. expand the width of the component
3. Add an additional column so there are three columns as opposed to one?

Thank you!!!!
 
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,force:lightningQuickAction,force:hasRecordId" access="global" controller="GSController">
	 <!-- Handle component initialization in a client-side controller -->
	 <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    
    <!-- Dynamically load the list of contacts -->
    <aura:attribute name="groupstructures" type="Group_Structure__c[]"/>
    <aura:attribute name="groupstructureList" type="Group_Structure__c[]"/>
    <aura:attribute name="totalGroupStructures" type="Integer"/>
    
    <!-- Page header with a counter that displays total number of contacts -->
    <div class="slds-page-header slds-page-header_object-home">
        <lightning:layout>
            <lightning:layoutItem>
                <lightning:icon iconName="standard:group_structure__c" />
            </lightning:layoutItem>
            <lightning:layoutItem class="slds-m-left_small">
                <p class="slds-text-title_caps slds-line-height_reset">Group Structures</p>
                <h1 class="slds-page-header__title slds-p-right_x-small">Group Structure Viewer</h1>
            </lightning:layoutItem>
        </lightning:layout>
    
        <lightning:layout>
            <lightning:layoutItem>
                <p class="slds-text-body_small">{!v.totalGroupStructures} Group Structures • View Group Structures Based on Status</p>
            </lightning:layoutItem>
        </lightning:layout>
    </div>
    
    <!-- Body with dropdown menu and list of Group Structures -->
    <lightning:layout>
        <lightning:layoutItem padding="horizontal-medium" >
            <!-- Create a dropdown menu with options -->
            <lightning:select aura:id="select" label="Status" name="source" 
                              onchange="{!c.handleSelect}" class="slds-m-bottom_small">
                <option value="">-- Select a Group Structure Status --</option>
                <option value="Active" text="Active"/>
                <option value="InActive" text="InActive"/>
                <option value="All" text="All"/>
            </lightning:select>
           
            <!-- Create a dropdown menu with options -->
            <lightning:select aura:id="selectHP" label="Health Product" name="sourceHP" 
                              onchange="{!c.handleSelect}" class="slds-m-bottom_small">
                 <option value="">-- Select a Horizon Product --</option>
                <option value="DA" text="DA"/>
                <option value="EPO Advantage" text="EPO Advantage"/>
                <option value="PPO" text="PPO"/>
                <option value="All" text="All"/>
            </lightning:select>
    
            <!-- Iterate over the list of Group Structures and display them -->
            <aura:iteration var="groupstructure" items="{!v.groupstructures}">
                  <c:GroupStructures groupstructure="{!groupstructure}"/>
            </aura:iteration>
        </lightning:layoutItem>
    </lightning:layout>
</aura:component>

 
  • September 19, 2018
  • Like
  • 0
I am using the e.force:createRecord and want to know if I can use the name (rather than ID) to pass the record type.
I know its not good practive to hardcode the ID's but unsure about how else to pass them.  Currently, I'm using:

{"entityApiName":"Opportunity","defaultFieldValues" :{ "AccountId": "#parentrecordid#", "RecordTypeId":"01239000000HrXEAA0", "Name":"Temp Name", "Region__c":"Inernational"}}

Thanks!!!

Fred
  • August 20, 2018
  • Like
  • 0
I have been working on this for quite a while without success. I posted this previously but did not get an answer.  I open a secnd component to add some records and when I save, I navigate back to the original component.  THe problem is that the newly created records do not display on the original component.  The odd thing is that the doint function does not fire when I navigate back. Therefore, my assumption is that the first component never closes when I navigate to the second component to create the records.  Please help!!!!! Trying to either close the first component out when I navigate to the second or refresh the first when I go back.  Here is the code on the second componet to save record and navigate back to first component.  thanks!!!!

Fred
 
insertGS : function(component, groupstructures, callback) {
 
		//call apex to save the newly created group structures
  		var action = component.get("c.saveGroupStructure");
        	action.setParams({gs: groupstructures
	        });
    
  $A.enqueueAction(action);
          
  ///This part of code is used to navigate back to the GroupStructuresList Component
        //variable to hold the account id for my naviagation back to original component
        var recordId = component.get("v.existinggroupstructure.Account__c")
        //set urlEvent Variable to navigate back to the original component
         var urlEvent = $A.get("e.force:navigateToURL");
        urlEvent.setParams({
            "url" : "lightning/n/Group_Structures_List?//Aid=" + recordId + "&Tid=123456789"    
        });
        ///navigate back to groupstructures page
        urlEvent.fire();

      
        },

 
  • December 10, 2018
  • Like
  • 1
I am trying to complete what I would think would be an easy task.. creating a new view.  However, I am on the Transaction Security page but I see no place to create a new view.  Also, I do not have the one page to create a new poicy.. .I have a wizard/lightning looking process.  Any help would be greatly appreciated!  Thanks!!  Fred
  • February 28, 2018
  • Like
  • 1
I have completed this Trail but when I add the map to the AllowLocator component, I receive an error, "Uncaught Action failed: c:AccountMap$controller$onAccountsLoaded [Cannot read property 'length' of null]
Callback failed: apex://AccountSearchController/ACTION$searchAccounts"

Any help would be greatly appreciated!!
  • March 23, 2020
  • Like
  • 0

I have turned on "Associate a Contact with Multiple Accounts".  I use a visualforce page to display my accounts and I'm trying to figure out the name of the related list to use.  

I used AccountContactRoles but I'm not getting the right page layout or buttons as expected.  thanks!!! 
 

Fred

  • February 20, 2019
  • Like
  • 0
I have been working on this for quite a while without success. I posted this previously but did not get an answer.  I open a secnd component to add some records and when I save, I navigate back to the original component.  THe problem is that the newly created records do not display on the original component.  The odd thing is that the doint function does not fire when I navigate back. Therefore, my assumption is that the first component never closes when I navigate to the second component to create the records.  Please help!!!!! Trying to either close the first component out when I navigate to the second or refresh the first when I go back.  Here is the code on the second componet to save record and navigate back to first component.  thanks!!!!

Fred
 
insertGS : function(component, groupstructures, callback) {
 
		//call apex to save the newly created group structures
  		var action = component.get("c.saveGroupStructure");
        	action.setParams({gs: groupstructures
	        });
    
  $A.enqueueAction(action);
          
  ///This part of code is used to navigate back to the GroupStructuresList Component
        //variable to hold the account id for my naviagation back to original component
        var recordId = component.get("v.existinggroupstructure.Account__c")
        //set urlEvent Variable to navigate back to the original component
         var urlEvent = $A.get("e.force:navigateToURL");
        urlEvent.setParams({
            "url" : "lightning/n/Group_Structures_List?//Aid=" + recordId + "&Tid=123456789"    
        });
        ///navigate back to groupstructures page
        urlEvent.fire();

      
        },

 
  • December 10, 2018
  • Like
  • 1
I have a lightning component that calls a second lightning component to clone records.  After I am done on this second component, I want to navigate back to the original and refresh it so it includes the new records.  I am able to return back to the original lightning component but the newly created records are not displaying unless I click refresh on browser.  How can I navigate and refresh?  THis is how I am returning to my original component on save:
 
createClones: function(component, GroupStructures) {
    //Save the expense and update the view
    console.log('### Im in the first function ' );
    this.upsertGS(component, GroupStructures, function(a) {
        //var groupstructures = component.get("v.newGroupStructures");
        GroupStructures.push(a.getReturnValue());
        component.set("v.newGroupStructures", GroupStructures);
    });
  },
    
    upsertGS : function(component, groupstructures, callback) {
        //variable to hold the account id for my naviagation back to original component
        var recordId = component.get("v.existinggroupstructure.Account__c")
        //set urlEvent Variable to navigate back to the original component
        var urlEvent = $A.get("e.force:navigateToURL");
        urlEvent.setParams({
            "url" : "lightning/n/Group_Structures_List?//Aid=" + recordId + "&Tid=123456789"    
        });
		//call apex to save the newly created group structures
  		var action = component.get("c.saveGroupStructure");
        	action.setParams({ 
          	gs: groupstructures
	  });
  if (callback) {
      action.setCallback(this, callback);
  }
        
  $A.enqueueAction(action);
        ///navigate back to groupstructures page
        urlEvent.fire();
},



Thanks!!

Fred
  • December 04, 2018
  • Like
  • 0
Hi.  I actually have two quesitons.  First, is the following a list or array?

var gs = []

Second, how do I determine the size of that variable?  console.log(gs.size()); renders an error

Finally, how do I determine the size of an attribute for a custom oject.  For example, I have the following attribute on my component:

<aura:attribute name="newGroupStructures" type="Group_Structure__c[]"/>

How can I write a console.log to see the size of that?

thanks!!!!

Fred
  • November 28, 2018
  • Like
  • 0
Hi.  I have been working on a cloning process that allows me to copy a record x number of times and then saving those copies as new records.

I am stuck on saving the records and returning to the original component.

I have the records saved in an attribute on the javascript controller but they are not getting passed to the controller  I suspect that my syntax is off or that I cannot pass multiple values.  So I have two problems that I'm asking for help with:
1. why am I getting a null pointer error on my apex class (the variable I'm passing to the apex class is not getting populated)
2. How can I pass the account ID back to my component (GroupStructures) so I can navigate back here after the save.

Any help would be greatly appreciated!!!

Here is the Component and Apex Class
({
	createClones: function(component, GroupStructures) {
    //Save the expense and update the view
    this.upsertGS(component, GroupStructures, function(a) {
        var groupstructures = component.get("v.newGroupStructures");
        groupstructures.push(a.getReturnValue());
        component.set("v.newGroupStructures", groupstructures);
    });
},
    
    upsertGS : function(component, GroupStructures, callback) {
        //set the return page
      	var evt = $A.get("e.force:navigateToComponent");
		evt.setParams({
            componentDef: "c:GroupStructures",
            componentAttributes :{ 
              recordId:groupstructure.Account__c
             }
        });
  var action = component.get("c.saveGroupStructure");
	  action.setParams({ 
          //I have confirmed that the values are in my variable in the js controller
      group_structure__c: GroupStructures
	  });
  if (callback) {
      action.setCallback(this, callback);
  }
  $A.enqueueAction(action);
        ///navigate back to groupstructures page
        evt.fire();
},
public class GSClone {
	@AuraEnabled

	public static group_structure__c saveGroupStructure (group_structure__c gs) {
    //public static group_structure__c saveGroupStructure (groupstructure gs) {
	system.debug ('### I got in the apex class' + gs);

	insert gs;
	return gs;
    
    }
}




 
  • November 26, 2018
  • Like
  • 0
I want to use a child component for each record and iterate over it on the main component.  For some reason, the values don't show when I try to use this approach.

If I simply iterate and use the recordEditForm it works fine.  However, once I try to use the second component the values do not show.  Here is my iteration from the primary component:
 
<aura:iteration var="groupstructure" items="{!v.newGroupStructures}">
                  <c:GSCloneRecord groupstructure="{!groupstructure}"/>
            </aura:iteration>

Here is the GSCloneRecord Component.  I am unsure of  how to reference the values in teh groupstructure attribute.  I tried adding value= but that did not seem to work.  Any help would be greatly appreciated!!! thanks!!!!
 
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,force:hasRecordId,lightning:isUrlAddressable" controller="GSController">
    <aura:attribute name="groupstructure" type="Group_Structure__c" />
	<!-- Handle component initialization in a client-side controller -->
	<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>

    <lightning:recordEditForm
             
            objectApiName="Group_Structure__c">
            <!-- the messages component is for error messages -->
            <lightning:messages />
  <lightning:layout multipleRows="true" verticalAlign="center" >
      <lightning:layoutItem size="1" padding="around-Small" >
 						<lightning:inputField aura:id="Name" fieldName="Name"   />
      				</lightning:layoutItem>

      
      
      <lightning:layoutItem size="1" padding="around-Small" >
 		<lightning:inputField fieldName="Status__c"/>
      </lightning:layoutItem>
      
     <lightning:layoutItem size="2" padding="around-Small">
        <lightning:inputField fieldName="Funding_Type__c"/>
     </lightning:layoutItem>
      <lightning:layoutItem size="1" padding="around-Small" class="customRequired">
    <lightning:inputField fieldName="Group_Number__c"/>
     </lightning:layoutItem>
    <lightning:layoutItem size="1" padding="around-Small" class="customRequired">
    <lightning:inputField fieldName="Section_Code__c"/>
     </lightning:layoutItem>
      <lightning:layoutItem size="1" padding="around-Small" class="customRequired">
       <div class="LSELabel">
        <lightning:inputField fieldName="Package_Code__c" />
      </div>
    </lightning:layoutItem>
    <lightning:layoutItem size="2" padding="around-Small" class="customDates">
        <lightning:inputField fieldName="Effective_Date__c"/>
    </lightning:layoutItem>
    <lightning:layoutItem size="2" padding="around-Small" class="customDates">
        <lightning:inputField fieldName="End_Date__c"/>
    </lightning:layoutItem>
      <lightning:layoutItem size="1" padding="around-Small" class="customProds">
        <lightning:inputField fieldName="Health_Product__c"/>
    </lightning:layoutItem>
    <lightning:layoutItem size=".5" padding="around-Small" class="customProds">
        <lightning:inputField fieldName="Prescription__c" />
    </lightning:layoutItem>
    <lightning:layoutItem size=".5" padding="around-Small" class="customProds">
      <lightning:inputField fieldName="Dental__c"/>
    </lightning:layoutItem>
    <lightning:layoutItem size=".5" padding="around-Small" class="customProds">
      <lightning:inputField fieldName="Vision__c"/>
    </lightning:layoutItem>
    <lightning:layoutItem size="1" padding="around-Small" class="customProds">
      <lightning:inputField fieldName="CDH_Status__c"/>
    </lightning:layoutItem>
    <lightning:layoutItem size="1" padding="around-Small" class="customRating">
      <lightning:inputField fieldName="Rating_Category__c"/>
    </lightning:layoutItem>
    <lightning:layoutItem size="3" padding="around-Small" class="customRating">
      <lightning:inputField fieldName="Coverage_Categories__c"/>
    </lightning:layoutItem>
    <lightning:layoutItem size="1" padding="around-Small">
      <lightning:inputField fieldName="Prefix__c"/>
    </lightning:layoutItem>
      <lightning:layoutItem size="5" padding="around-Small">
        <lightning:inputField fieldName="Description__c"/>
    </lightning:layoutItem>
        </lightning:layout>
        </lightning:recordEditForm>

</aura:component>



 
  • November 20, 2018
  • Like
  • 0
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:
 
  
<!-- 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);
  },


 
  • October 26, 2018
  • Like
  • 0
I have a component that display a listing of records.  When clicking a button on that list, I am opening a second component.   The first component will pass data to the first component to clone the record.  What is the best way to do this?  I think that I would need to use an event but then I saw some posts (that I could not fully understand) that talked about the concept of parent and child components.

I'm just trying to find the best way to open the second component and pre-populate values.  The record will be saved and the user should be directed back to the original component.

thanks!!

Fred
  • October 23, 2018
  • Like
  • 0
Can anyone advise how I can get variable from a url and store them as attributes that I can use to filter data?  Here is my current url:

lightning/n/Group_Structures_List?Aid=001q000000nv4YT&Tid=001q000000nv52W

I need to understand how I create two different variables... Aid should hold the id that follows the and Tid should hold the id that follows.

Thank you!!

Fred
  • October 16, 2018
  • Like
  • 0
Is there a way that I can actually see the contents of the variable I create rather than just object?  In sample below, I am printing to the console log the value of the components v.groupstructureList... but when I look at the console in chrome, I just see object and not the actual values? thanks!!!

Fred

User-added image
  • October 04, 2018
  • Like
  • 0
I have a list of strings that I want to display on my component.  The issue I am currently having is actually displaying the values in the attribute.

My attribute is: <aura:attribute name="groupnumbers" type="group_structure__c[]" />

My select field is: 
<lightning:layoutItem padding="around-small">
            <!-- Create a dropdown menu with options for Section code-->
            <lightning:select aura:id="selectGroupNum" label="GroupNum" name="sourceGroupNum" onchange="{!c.handleSelect}">
          			 <aura:iteration items="{!v.groupnumbers}" var="gs">
            		<option value="{!gs}">{!gs.label}</option>
        		 </aura:iteration>
            </lightning:select>
     	 </lightning:layoutItem>

I am certain that my option value is the issue.  How do I display the attribute when it is just a list of strings?  Also, can I set a default?

Thank you!!!!

Fred
  • October 02, 2018
  • Like
  • 0
We have created a lightning component. Inisde the component we are refering another component. we would like to validate the data inside child component on a button click from parent component.

Can anyone give some sample code or suggestion?

Thanks and RegardsUser-added image
Here we call child component

<div class="slds-modal__content slds-p-around--medium wide400">
                <!--Transaction Editor Component Here -->
                <!--<c:TransactionViewer thistrans="{!v.thistrans}" currencies="{!v.currencies}" 
                           tdetails="{!v.thisdetails}" /> -->
             {!v.body}
</div>


below is component  code is long so I paset only 2 field code


<div class="slds-form-element slds-size--1-of-3">
                            <!--<label class="slds-form-element__label" for="descrField">Description</label>-->
                            <!--<force:inputField aura:id="descrField" class="slds-textarea" value="{!v.thistrans.Description__c}"/> -->
                            <ui:inputText aura:id="descrField" class="slds-input" required="true" label="Description" value="{!v.thistrans.Description__c}"/>
                        </div>
                        <div class="slds-form-element slds-size--1-of-3">                            
                            <c:LookupSObject label="Deal/Tranche" pluralLabel="Deal/Tranches" sObjectAPIName="Tranche__c" instanceId="tnxTr"                          
                                             
                                             iconName="standard:process"
                                             listIconClass="slds-icon-standard-account"
                                             selectedId="{!v.thistrans.Tranche__c}"
                                             selectedName="{!v.thistrans.TName}"
                                             />
                        </div>

And here is controller code
 
okTranerror: function(component){
        var tratitle = component.find("trannameField").get("v.value");
        var haserrors = false;
        
        if(!tratitle){            
            effnamefld.set("v.errors", [{message:"Provide Name First!"}]);
            haserrors = true;
        }
please help i m try a lot but not success

thanks in advance 
Hi All,
I am generating  Pdf for Account object using lightning components.in that client side controller file it will through 
component.setParams() callback failed..i passed the accountId also but getting same error.can any one help me on this issue becuase i am new to lightning exp.
my code is
apex cls
public class TextVFPDFController {
    public Account acc{get;set;}
    public TextVFPDFController(){
        Id accId = apexpages.currentpage().getparameters().get('id');
        acc = [select id,Name from Account where id=: accId];
    }
}

vf page
<apex:page controller="TextVFPDFController" renderAs="PDF">
    {!acc.Name}
</apex:page>

component

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" controller="TestAppController" >
    <aura:attribute name = "accountId" type = "Account" />
    <lightning:button variant = "brand" label = "Generate Pdf" onclick = "{!c.savePDF}" />
</aura:component>

client-side controller.js

({
    savePDF : function(component, event, helper) {
        var action = component.get("c.savePDFAccount");
        action.setCallback(this, function(response) {
            component.setParams({"recordId" : component.get("v.accountId")});
            var state = response.getState();
            if (state === "SUCCESS") {
                component.set("v.recordId",response.getReturnValue());
                alert('Attachment saved successfully');
                              
            }        
               else {
                        console.log("Unknown error");
                    }
                
        });
        $A.enqueueAction(action);
    }
})

server-side controller.cls

public class TestAppController {
    @auraEnabled
    public static void savePDFAccount(String recordId){
        PageReference pdfPage = new PageReference('/apex/TextVFPDF');
        pdfPage.getParameters().put('Id',recordId);
        Blob pdfContent = pdfPage.getContent();
        Attachment attach1= new Attachment();
        //attach1.ParentId = parentId;
        attach1.Name = 'Test Attachment for PDF';
        attach1.Body = pdfContent;
        attach1.contentType = 'application/pdf';
        insert attach1;
        
    }
}

and the error is

Uncaught Error in $A.getCallback() [component.setParams is not a function]
Callback failed: apex://TestAppController/ACTION$savePDFAccount

can any one help this issue
thanks in advance
 
  • October 10, 2018
  • Like
  • 1