• Alexander Atkinson
  • NEWBIE
  • 20 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 11
    Questions
  • 9
    Replies
Hi I have a visual force page that shows a table of information. One of the columns is a checkbox. You can check and uncheck these individually and their values are successfully sent or removed from apex. Whatever is checked is sent to a new page to be shown as a quote.

I'm trying to implement a "check all boxes" main checkbox at the top of my page and pass all the data in.

Visual Force:
<table width="100%" class="data-table">
                <tr class="headerRow">
                    <th style="font-size: 14px; font-weight: bold; text-align: center" width="4%">Select <!--Checkall box underneath this--></th>
                </tr>
                <tr height="2px"></tr>
                <apex:repeat value="{!data}" var="Results">
                    <tr>
                        <td style="text-align: center" width="4%"><input type="checkbox" value="{!Results.Id}" onChange="quotesCheck('{!Results.id}', this.checked);" /></td>
					</tr>
                    <tr height="2px">
                    </tr>
                </apex:repeat>
			</table>
						
			<apex:actionFunction action="{!addQuotesToChecked}" name="quotesCheck" reRender="sasa">
                <apex:param name="quoteId" value=""/> 
                <apex:param name="chkValue" value=""/>
        	</apex:actionFunction>

Apex function being called:
public PageReference addQuotesToChecked()
    {
        string quoteId = Apexpages.currentPage().getParameters().get('quoteId');
        string chkValue = Apexpages.currentPage().getParameters().get('chkValue');
        System.debug('quoteId '+quoteId);
        System.debug('chkValue '+chkValue);
        if(checkedQuotes ==null)
        {
            system.debug('null again');
            checkedQuotes= new List<id>();
            checkedQuotes.add(quoteId);
        }
        else
        {
            if(chkValue=='true')
            {
                checkedQuotes.add(quoteId);
            }
            else
            {
               integer i= checkedQuotes.indexOf(quoteId);
                checkedQuotes.remove(i);
            }
             
        }
        integer i=checkedQuotes.size();
        system.debug(i);
       
        return null;
    }

 
I have a table of items. Each item can be selected or checked with a checkbox, and an OnChange is triggered to pass its ID to Apex for a query that will quote the selected items.
This works all fine for individual checking. However I just added a page component that checks all the items if the "Select All" box is checked. This "works" also, it ticks all the boxes on the table. However the OnChange is not triggered so no ID's are passed to Apex for the query resulting in no quote data.

Visual Force Page Snippet:
<apex:page>
    <table>
        <tr class="headerRow">
            <th style="font-size: 14px; font-weight: bold; text-align: center" width="4%">
                <br/>Select<br/>
                <c:CheckAllOrNone />
            </th>
            </tr>
            <apex:repeat value="{!data}" var="Results">
            <tr>
                <td style="text-align: center" width="4%"><input type="checkbox" value="{!Results.Id}" onChange="quotesCheck('{!Results.id}', this.checked);" /></td>
            </tr>
        </apex:repeat>
    </table>
</apex:page>
Visual Component: 
<apex:component >
    <script>
    function cvCheckAllOrNone(allOrNoneCheckbox) {

        // Find parent table
        var container = allOrNoneCheckbox;
        while (container.tagName != "TABLE") {
            container = container.parentNode;
        }

        // Switch all checkboxes
        var inputs = container.getElementsByTagName("input");
        var checked = allOrNoneCheckbox.checked;
        for (var i = 0; i < inputs.length; i++) { 
            var input = inputs.item(i);
            if (input.type == "checkbox") {
                if (input != allOrNoneCheckbox) {
                    input.checked = checked;
                }
            }
        }
    }
    </script>

    <apex:inputCheckbox onclick="cvCheckAllOrNone(this)" title="Toggle All Rows"/>
</apex:component>

Apex Snippet
public PageReference addQuotesToChecked()
{
    string quoteId = Apexpages.currentPage().getParameters().get('quoteId');
    string chkValue = Apexpages.currentPage().getParameters().get('chkValue');
    System.debug('quoteId '+quoteId);
    System.debug('chkValue '+chkValue);
    if(checkedQuotes ==null)
    {
        checkedQuotes= new List<id>();
        checkedQuotes.add(quoteId);
    }
    else
    {
        if(chkValue=='true')
        {
            checkedQuotes.add(quoteId);
        }
        else
        {
           integer i= checkedQuotes.indexOf(quoteId);
            checkedQuotes.remove(i);
        }

    }
    integer i=checkedQuotes.size();

    return null;
}

The Apex code works, and so does the visual force code. Ticking individually passes data. Mass checking with the page component however doesn't.


 
Hello i've made a visual force page. I have a footer containing general terms and conditions, but I only want it on the last page. My problem is the footer appears on every page right now.

Help would be appreciated, thanks!
<apex:page >
        
    <head>
        <style>
            .footer {
                position: fixed;
                left: 0;
                bottom: 0;
                width: 100%;
                text-align: center;
            }     

        </style>
    </head>

    <body>
        <img src="{!$Resource.Logo}" align="right" style="vertical-align: top;" width="25%"/>
        <div>
             Main content here
	</div>
        <div class="footer">
            <hr/>
                stuff here on bottom of last page
            </p>
        </div>
    </body>
</apex:page>

 
Hello, I'm trying to implement a save to pdf functionality to my visual force page, but have ran into a problem of "Too many nested getContent calls".

Visual Force Page
<apex:page showHeader="false" standardStylesheets="false"
    standardController="Event__c" extensions="SaveAsPdfExtension" action="{!savePdf}">

    <header>
        <h1 align="center">VIPs for {!Event__c.Name}</h1>
    </header>
    <apex:repeat value="{! VIPs }" var="Guest">
        <section class="container">
          <div>
            <article>
                <h2>Name: {!Guest.Guest_Name__c }</h2>
                <h3>Description:</h3>
                <p>{!Guest.Guest__r.Description }</p>
            </article>
          </div>
        </section>
    </apex:repeat>
</apex:page>

Apex code for the savePDF
public PageReference savePdf() 
    {
        PageReference pdf = Page.Event_Crib_Sheet;
        pdf.getParameters().put('id',Event.Id);
        Attachment attach = new Attachment();
        Blob body;
        try
        {
            body = pdf.getContentasPDF();    
        } 
        catch (VisualforceException e) 
        {
            body = Blob.valueOf(e.getMessage());
        }
        
        attach.Body = body;
        attach.Name = pdfName;
        attach.IsPrivate = false;
        attach.ParentId = Event.Id;
        attach.Description = 'Created by ' + UserInfo.getName();
        
        insert attach;

        return new PageReference('/'+ Event.Id);
    }

 
Hello, I have a Visual Force Page that displays a table of information / records. Each row has a checkbox to represent if it has been selected or not.
There is a button called "Quote Selected".

My goal here is when this button is pressed, all the items on the table that are selected have their information / ids passed to a list in another Apex controller that can be used on my 2nd VFP to generate a quote.

VFP:
<apex:form>
            <table width="100%" class="data-table">
                <tr class="headerRow">
                    <th>Select</th>
                    <th>SUPPLIER</th>
                    <th>DAY RATE</th>
                    <th>STANDING CHARGE</th>
                    <th>TERM</th>
                    <th>ANNUAL CHARGE</th>
                    <th>TOTAL AMOUNT</th>
                    <th>EXTRA INFORMATION</th>
                </tr>
                <apex:repeat value="{!data}" var="Results">
                    <tr>
                        <td>{!Results}<input type="checkbox" value="{!Results}"/></td>
                     	<td><apex:outputField value="{!Results.Supplier__c}"/></td>
                     	<td><apex:outputField value="{!Results.Day_Rate__c}"/></td>
                     	<td><apex:outputField value="{!Results.Standing_Charge__c}"/></td>
                     	<td><apex:outputField value="{!Results.Term__c}"/></td>
                     	<td><apex:outputField value="{!Results.Annual_Charge__c}"/></td>
                     	<td><apex:outputField value="{!Results.Total_Amount__c}"/></td>   
                     	<td><apex:outputField value="{!Results.Extra_Info__c}"/></td>
		    </tr>
                </apex:repeat>
		</table>

		<apex:commandButton action="{!quoteSelected}" value="Quote Selected"/>
        </apex:form>

 
Hello, I have created a flow for an event planner. It creates an event, tables, and seats for the event.
However when I try to create more than 100 records the flow fails. Is there any way to fix this?

Image of my flow:

User-added image
Hello, I'm trying to call an event handler but it doesn't seem to be working.

Card controller:
onDrop: function(component, event, helper)
    {
        event.preventDefault();
        
		var index = component.get('v.index');
		var seatNumber = component.get('v.seatNumber');
        console.log("Target Item Index:",index,"\nTarget Item Seat:",seatNumber); //These work, and have values.

		var cardSwapEvent = component.getEvent('cardSwapRegister');
        cardSwapEvent.setParams({'seatNumber': seatNumber, 'index': index}); 
        cardSwapEvent.fire();
        
        console.log("CardonCard");
	}

Main component
<aura:component controller="DragDropApexController" implements="force:appHostable,flexipage:availableForAllPageTypes,force:hasRecordId,force:lightningQuickAction">

	<!-- event handlers -->
	<aura:handler name="init" action="{!c.doInit}" value="{!this}"></aura:handler>
    <aura:handler name="cardSwapped" event="c:CardSwap" action="{!c.onCardSwapped}"></aura:handler>
Main component controller
onCardSwapped: function(component, event, helper)
    {
        console.log("onCardSwapped"); //This isn't logging in the console meaning the function isn't calling.
		
		 //Code here to swap the 2 cards information
		 
	},


 
So I have some code that is really inefficient. It has an array of objects all created from an apex query. When I move somebody to a new location, the component will fire an event with the moved persons information stored. This is then used in a "find" method for my array of objects to find the object inside of the array to edit and update so the component will update visually.

The problem is this line of code becomes extremely inefficient when passing 200 objects.

Sample:
 
var titleid = event.getParam("titleid");
        var title = event.getParam("title");
        var maxSeats = event.getParam("maxSeats");
        var seatsInUse = event.getParam("seatsInUse");  
        var item = event.getParam("item"); //This is the item that was moved.
        var allGuestsList = component.get("v.allItems"); //This is the array of objects
        
        //Search guest list for matching guest to edit the array so the component will update graphically.
        var actualGuest = allGuestsList.find(function(moving){return moving.id == item.id;}); //***REALLY INEFFICIENT***

 
Hi, in my lightning component I have a series of tables generated and displayed each in their own column through an Aura:Iteration.
The problem is I have 60 items or more to display.

Is there any way to set a max columns per row? So once it has generated 10, it moves onto row 2 to create another 10 and so on.

Component Code:
<div class="columns">
    <aura:iteration items="{!v.allTables}" var="Table">
        <c:Pipeline title="{!Table.Name}" titleid="{!Table.Id}" items="{!v.allItems}"></c:Pipeline>
    </aura:iteration>
</div>
Hi, I'm having understanding how to update my database of accounts with new field values based on component item variables.
Below are the fields, and the values they need to be set to.
  • name = item.title
  • id = item.id
  • table_number__c = item.status

JavaScript Controller: 
updateAccounts: function(component, event, helper) 
    {
        var action = component.get("c.updateAccounts");
        var itemsToPass = component.get("v.allItems"); //Items in the component
        var AccountsToUpdate = []; //Items that will be sent to 
        
        //Go through items in the component.
        //Create a list of accounts. Account name = itemname, Account id = item id, Table Name = Status
        for (var i=0; i< itemsToPass.length; i++)
        {
            var item = itemsToPass[i];
            var Account = {Name: item.title, Id: item.Id, Table_Name__c: item.status};

            //Push each account to the array.
            AccountsToUpdate.push(Account);
        } 
        //Pass the array into Apex list.
        action.setParams({ "changes": AccountsToUpdate  });
        $A.enqueueAction(action); 
    }
Apex Controller:
public with sharing class AccountController 
{
    @AuraEnabled
    public static List<Account> getAccounts() 
    {
        List<Account> Accounts =  [SELECT Id, Name, TableName__c FROM Account];
        return Accounts;
    }
    
	@AuraEnabled
    public static List<Account> updateAccounts (List<Account> changes)
    {
        update changes;
        return changes;
    }
}
Component:
<aura:component>	
	<aura:attribute name="allItems" type="list"></aura:attribute>

    <lightning:button label="Save Plan" iconName="utility:save" onclick="{!c.updateAccounts}"/>
</aura:component>


 
Hello I am creating a lightning component. 
I have a list of accounts obtained by a query in an apex class. I want to send this list to an array in a javascript controller that will let me assign the record values to variables.

Apex:
public with sharing class AccountController 
{
    @AuraEnabled
    public static List<Account> getAccounts() 
    {
        List<Account> Accounts =  [SELECT Id, Name FROM Account];
        return Accounts;
    }
}

JavaScript controller:
    doInit: function(component, event, helper) 
    {
        ///Obtain account record list from Apex SOQL and pass it to an array.
        //var records = [] ???
  
        //This list is what will be passed to lightning component when function ends.
        var newItems=[];
        
        //Loop through records array and create item list using record field values.
        for (var i=0; i< records.length; i++)
        {
            var record = records[i];
            var Item = {title: record.name, id: record.id, status: "Unassigned"};
            newItems.push(Item);
        }  
        //Pass items into component
        component.set("v.allItems", newItems);
    },
I have a table of items. Each item can be selected or checked with a checkbox, and an OnChange is triggered to pass its ID to Apex for a query that will quote the selected items.
This works all fine for individual checking. However I just added a page component that checks all the items if the "Select All" box is checked. This "works" also, it ticks all the boxes on the table. However the OnChange is not triggered so no ID's are passed to Apex for the query resulting in no quote data.

Visual Force Page Snippet:
<apex:page>
    <table>
        <tr class="headerRow">
            <th style="font-size: 14px; font-weight: bold; text-align: center" width="4%">
                <br/>Select<br/>
                <c:CheckAllOrNone />
            </th>
            </tr>
            <apex:repeat value="{!data}" var="Results">
            <tr>
                <td style="text-align: center" width="4%"><input type="checkbox" value="{!Results.Id}" onChange="quotesCheck('{!Results.id}', this.checked);" /></td>
            </tr>
        </apex:repeat>
    </table>
</apex:page>
Visual Component: 
<apex:component >
    <script>
    function cvCheckAllOrNone(allOrNoneCheckbox) {

        // Find parent table
        var container = allOrNoneCheckbox;
        while (container.tagName != "TABLE") {
            container = container.parentNode;
        }

        // Switch all checkboxes
        var inputs = container.getElementsByTagName("input");
        var checked = allOrNoneCheckbox.checked;
        for (var i = 0; i < inputs.length; i++) { 
            var input = inputs.item(i);
            if (input.type == "checkbox") {
                if (input != allOrNoneCheckbox) {
                    input.checked = checked;
                }
            }
        }
    }
    </script>

    <apex:inputCheckbox onclick="cvCheckAllOrNone(this)" title="Toggle All Rows"/>
</apex:component>

Apex Snippet
public PageReference addQuotesToChecked()
{
    string quoteId = Apexpages.currentPage().getParameters().get('quoteId');
    string chkValue = Apexpages.currentPage().getParameters().get('chkValue');
    System.debug('quoteId '+quoteId);
    System.debug('chkValue '+chkValue);
    if(checkedQuotes ==null)
    {
        checkedQuotes= new List<id>();
        checkedQuotes.add(quoteId);
    }
    else
    {
        if(chkValue=='true')
        {
            checkedQuotes.add(quoteId);
        }
        else
        {
           integer i= checkedQuotes.indexOf(quoteId);
            checkedQuotes.remove(i);
        }

    }
    integer i=checkedQuotes.size();

    return null;
}

The Apex code works, and so does the visual force code. Ticking individually passes data. Mass checking with the page component however doesn't.


 
Hello i've made a visual force page. I have a footer containing general terms and conditions, but I only want it on the last page. My problem is the footer appears on every page right now.

Help would be appreciated, thanks!
<apex:page >
        
    <head>
        <style>
            .footer {
                position: fixed;
                left: 0;
                bottom: 0;
                width: 100%;
                text-align: center;
            }     

        </style>
    </head>

    <body>
        <img src="{!$Resource.Logo}" align="right" style="vertical-align: top;" width="25%"/>
        <div>
             Main content here
	</div>
        <div class="footer">
            <hr/>
                stuff here on bottom of last page
            </p>
        </div>
    </body>
</apex:page>

 
Hello, I have a Visual Force Page that displays a table of information / records. Each row has a checkbox to represent if it has been selected or not.
There is a button called "Quote Selected".

My goal here is when this button is pressed, all the items on the table that are selected have their information / ids passed to a list in another Apex controller that can be used on my 2nd VFP to generate a quote.

VFP:
<apex:form>
            <table width="100%" class="data-table">
                <tr class="headerRow">
                    <th>Select</th>
                    <th>SUPPLIER</th>
                    <th>DAY RATE</th>
                    <th>STANDING CHARGE</th>
                    <th>TERM</th>
                    <th>ANNUAL CHARGE</th>
                    <th>TOTAL AMOUNT</th>
                    <th>EXTRA INFORMATION</th>
                </tr>
                <apex:repeat value="{!data}" var="Results">
                    <tr>
                        <td>{!Results}<input type="checkbox" value="{!Results}"/></td>
                     	<td><apex:outputField value="{!Results.Supplier__c}"/></td>
                     	<td><apex:outputField value="{!Results.Day_Rate__c}"/></td>
                     	<td><apex:outputField value="{!Results.Standing_Charge__c}"/></td>
                     	<td><apex:outputField value="{!Results.Term__c}"/></td>
                     	<td><apex:outputField value="{!Results.Annual_Charge__c}"/></td>
                     	<td><apex:outputField value="{!Results.Total_Amount__c}"/></td>   
                     	<td><apex:outputField value="{!Results.Extra_Info__c}"/></td>
		    </tr>
                </apex:repeat>
		</table>

		<apex:commandButton action="{!quoteSelected}" value="Quote Selected"/>
        </apex:form>

 
So I have some code that is really inefficient. It has an array of objects all created from an apex query. When I move somebody to a new location, the component will fire an event with the moved persons information stored. This is then used in a "find" method for my array of objects to find the object inside of the array to edit and update so the component will update visually.

The problem is this line of code becomes extremely inefficient when passing 200 objects.

Sample:
 
var titleid = event.getParam("titleid");
        var title = event.getParam("title");
        var maxSeats = event.getParam("maxSeats");
        var seatsInUse = event.getParam("seatsInUse");  
        var item = event.getParam("item"); //This is the item that was moved.
        var allGuestsList = component.get("v.allItems"); //This is the array of objects
        
        //Search guest list for matching guest to edit the array so the component will update graphically.
        var actualGuest = allGuestsList.find(function(moving){return moving.id == item.id;}); //***REALLY INEFFICIENT***

 
Hi, I'm having understanding how to update my database of accounts with new field values based on component item variables.
Below are the fields, and the values they need to be set to.
  • name = item.title
  • id = item.id
  • table_number__c = item.status

JavaScript Controller: 
updateAccounts: function(component, event, helper) 
    {
        var action = component.get("c.updateAccounts");
        var itemsToPass = component.get("v.allItems"); //Items in the component
        var AccountsToUpdate = []; //Items that will be sent to 
        
        //Go through items in the component.
        //Create a list of accounts. Account name = itemname, Account id = item id, Table Name = Status
        for (var i=0; i< itemsToPass.length; i++)
        {
            var item = itemsToPass[i];
            var Account = {Name: item.title, Id: item.Id, Table_Name__c: item.status};

            //Push each account to the array.
            AccountsToUpdate.push(Account);
        } 
        //Pass the array into Apex list.
        action.setParams({ "changes": AccountsToUpdate  });
        $A.enqueueAction(action); 
    }
Apex Controller:
public with sharing class AccountController 
{
    @AuraEnabled
    public static List<Account> getAccounts() 
    {
        List<Account> Accounts =  [SELECT Id, Name, TableName__c FROM Account];
        return Accounts;
    }
    
	@AuraEnabled
    public static List<Account> updateAccounts (List<Account> changes)
    {
        update changes;
        return changes;
    }
}
Component:
<aura:component>	
	<aura:attribute name="allItems" type="list"></aura:attribute>

    <lightning:button label="Save Plan" iconName="utility:save" onclick="{!c.updateAccounts}"/>
</aura:component>


 
Hello I am creating a lightning component. 
I have a list of accounts obtained by a query in an apex class. I want to send this list to an array in a javascript controller that will let me assign the record values to variables.

Apex:
public with sharing class AccountController 
{
    @AuraEnabled
    public static List<Account> getAccounts() 
    {
        List<Account> Accounts =  [SELECT Id, Name FROM Account];
        return Accounts;
    }
}

JavaScript controller:
    doInit: function(component, event, helper) 
    {
        ///Obtain account record list from Apex SOQL and pass it to an array.
        //var records = [] ???
  
        //This list is what will be passed to lightning component when function ends.
        var newItems=[];
        
        //Loop through records array and create item list using record field values.
        for (var i=0; i< records.length; i++)
        {
            var record = records[i];
            var Item = {title: record.name, id: record.id, status: "Unassigned"};
            newItems.push(Item);
        }  
        //Pass items into component
        component.set("v.allItems", newItems);
    },