• Fred13
  • NEWBIE
  • 109 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 1
    Likes Given
  • 29
    Questions
  • 50
    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
When using lightning datatable and displaying a date field, its showing a day less than the value in the backend object.

Controller:
component.set('v.Columns',[
                {label:'Transport. mode', fieldName:'Mode_of_Transportation__c', type:'text', editable: false,initialWidth:180},
                {label:'Ground Company', fieldName:'Ground_Transportation_Company__c', type:'text', editable: false,initialWidth:210},
                {label:'Inv./Chg. date', fieldName:'Charge_Invoice_Date__c', initialWidth:150, type:'date', editable: false , typeAttributes:{month:'2-digit',day:'2-digit',year:'numeric'}}
            ]

Datatable:

            <lightning:datatable aura:id="OppExpGTDataTable"
                                 data="{! v.Opp_Expenses_GTXYZ }" 
                                 columns="{! v.Columns }" 
                                 keyField="Id"
                                 onsave ="{!c.onSave}"
                                 hideCheckboxColumn="true"
                                 onrowaction="{! c.handleRowAction }"/>

Using a custom pop up, we are creating records into database capturing date values. Its getting stored in database properly, when displaying in UI, its showing a day less. In out of the box fields, its showing correctly again. How to format the field in lightning datatable/controller? Appreciate your help..
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 record edit form that works for me, but "rarely" works for another user (I'm logging in as that user to test this) -- but here's the kicker -- *until* they go do other stuff and come back later.

The lightning component consists of a lightning:recordEditForm that has several fields including about 4 lookup fields (Account, Contact, managed obj Vehicle Inventory and managed obj Location). One of the lookups is to a custom object, and gets a default value based on the user's settings. When creating a new record, the default value shows up properly. The record is saved and that location lookup value is in the record -- it's visible in the "Recent items" related list.  But when this user re-opens the record that value isn't there anymore. 

When the value will NOT display on-screen I'm seeing an error 4 times in my Chrome consols: "Cannot read property 'color' of undefined.'  This error occurs *between* the completion of my "init" handler and the start of the RecordEditForm's onload method. The "setDefaultLocation" routine runs correctly when initiating a new record, but does not run (and shouldn't) when displaying an existing record with the value specified.

I've verified that the user has read & edit authority on all fields in the object and can read the target object of the lookup field. And again, if I log off as this user, then log in as this user again (or just go on to other things and come back later), then the lookup field is properly displayed.

I think the full code is too much for the forum, but here are some snippets:

<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId,force:appHostable,lightning:actionOverride"
    controller="RentalAgreementLex">
...
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
...
<lightning:recordEditForm recordId="{!v.recordId}" objectApiName="dealer__Rental_Agreements__c"
    aura:id="newrecordform" onsuccess="{!c.recordSaved}" onerror="{!c.recordSaveError}"
    onload="{!c.pageload}">
...
            <lightning:inputField fieldName="Location__c" disabled="{!v.alreadyposted}" aura:id="location"
                required="true" readonly="{!v.alreadyposted}" class="mw_required"/>


Some of the controller code:
/* general page initializations */
    doInit : function(component, event, helper) {
        console.log('doInit');
        // initialize that we're not in the process of posting
        component.set("v.posting", false);
...
        console.log('doInit complete');
    },
    /* initializations when recordeditform is loaded */
    pageload: function(component, event, helper) {
        console.log('pageload');
        let id = component.get("v.recordId");
        console.log(id);
        let sts = (id==null) ? null : component.find("agreement_status").get("v.value");
        if (id==null) {
            sts = 'Open';   // default value
            let stscmp = component.find("agreement_status");
            if (stscmp!=null) stscmp.set("v.value", sts);
            component.set("v.status", sts); // also init record data status
            component.find("deposit_amount").set("v.value",0.00);   // default value
            component.find("excess_miles_charge").set("v.value",0.00);  // default value
            component.set("v.title","New Rental Agreement");
            component.find("totalperdiemtax").set("v.value",0.00);  // default value
            component.find("sales_tax").set("v.value",0.00);    // default value
            component.find("countysalestax").set("v.value",0.00);   // default value
            component.find("citysalestax").set("v.value",0.00); // default value
            component.find("thirdtierrentaltax").set("v.value",0.00);   // default value
        }
        // in doInit: component.set("v.title", name);
        let isopen = sts!='Paid';
        let posting = component.get("v.posting");
        console.log('isopen = ' + isopen);
        // enable/disable buttons based on rental status
        if (!posting && isopen) component.find("submitbutton").set("v.disabled", false);
        if (!posting && id!=null && isopen) component.find("postbutton").set("v.disabled",false);
        let fromaccount = component.get("v.fromaccount");
        if (fromaccount!==null) {
            component.find("account").set("v.value",fromaccount);
            helper.rtvPersonContactId(component, event);
        }
        let fromcontact = component.get("v.fromcontact");
        if (fromcontact!==null) {
            component.find("contact").set("v.value",fromcontact);
            helper.rtvContactsAccountId(component, event);
        }
        if (isopen) component.set("v.alreadyposted", false);
        else component.set("v.alreadyposted", true);
        // set default location
        let c_location = component.find("location");
        let location = null;
        if (c_location!=null) location = c_location.get("v.value");
        if (id==null && location==null) helper.rtvUserDefaultLocation(component, event);
        // initialize running totals
        helper.recalcTotals(component, event);
        console.log('pageLoad complete');
    },
 
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
I am just starting through the Lightning Components Basics Trailhead.  I have a few questions.  The first is, how do you pass data or get data to a component?  For example, I am working on the Handle Actions And Conrollers module.  I built the 'campingListItem Component and Controller but there is no data that shows when I launch the component.  Maybe I'm not there yet but I'm confused how you pass data to the component.

The second question I have is specifically about the challenge for the 'Handle Actions and Controllers" Module.  I completed it successfully, but I'm not sure if what I have is the most efficent way to go about it.  I am pasting my controller below.  The first variable is pulling in the button so I can disable it (btnClicked)  The second variable is getting the item and updating fields form that item.

Thank you!!!

Fred

var btnClicked = event.getSource();
        btnClicked.set("v.disabled",true);
 var a = component.get("v.item",true);
         a.Packed__c = true;
         component.set("v.item",a);
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