• Alex P
  • NEWBIE
  • 0 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies
Trying to test my first component for pulling quote line items into a VF email template. Any help greatly appreciated! 
VF Component:
<apex:component access="global" controller="SortedLineItemsController">
<apex:attribute name="value" type="Quote" assignTo="{!quote}" description="TODO: Describe me"/>

<apex:repeat var="li" value="{!sorted}">
<tr>
<td>{!li.Part_Name__c}</td>
<td>{!li.Technology_Pick__c}</td>
<td>{!li.Rev__c}</td>
<td>{!li.Material__c}</td>
<td>{!li.Description_Summary__c}</td>
<td>${!li.UnitPrice}</td>
<td>{!li.Quantity}</td>
<td>${!li.TotalPrice}</td>
</tr>
</apex:repeat>

<!-- Needed to work around limitation that the standard controller cannot "see"
the linkage between the value attribute and the opportunity property -->
<apex:variable var="oli" value="{!value.QuoteLineItems}" rendered="false">
{!oli.Part_Name__c}
{!oli.Technology_Pick__c}
{!oli.Rev__c}
{!oli.Material__c}
{!oli.Description_Summary__c}
{!oli.UnitPrice}
{!oli.Quantity}
{!oli.TotalPrice}
</apex:variable>
</apex:component
Apex Controller:
public class SortedLineItemsController {
    public Quote quote { get; set; }
    
    public QuoteLineItem[] getSorted() {
        if (quote == null || quote.quoteLineItems== null) {
            return null;
        }
        
        
        QuoteLineItem[] result = new QuoteLineItem[1];
        for (QuoteLineItem item : Quote.quoteLineItems) {
            result.add(0, item);
        }
        
        return result;
   }
}

​​​​​​​
I was hoping someone could assist me with a Lightning Component quick action. I am trying to make a quick action on the Opportunity to create a new quote. The only field I am looking to show is the quote name field. I have the button but when I click the "Create Quote" nothing happens. I am very new to the dev side of SFDC and I gleamed all the code from research. Can anyone take a look at my code and see whats up?
New Quote Button
Component:

<aura:component controller="QuickQuote"
                implements="force:lightningQuickActionWithoutHeader">
    <aura:attribute name="recordId" type="String" />
    <aura:attribute name="newQuote" type="Quote"/>
        <div class="slds-page-header" role="banner">
        <h1 class="slds-page-header__title slds-m-right--small
                   slds-truncate slds-align-left">Create New Quote</h1>
    </div>
    <lightning:input aura:id="quoteName" 
                     name="Quote Name" 
                     label="Quote Name" 
                     value="{!v.newQuote.QuoteToName}"
                     required="true"/>
	
 <lightning:button label="Create Quote" onclick="{!c.createQuote}"
                      class="slds-m-top--medium"/>
    
  
    
    
</aura:component>

Controller:

({
    createQuote: function(component, event, helper) {
        var saveAction = component.get("c.saveQuote");
        console.log('saveAction');
        saveAction.setParams({
            newQuote: component.get("v.newQuote"),
            oppId: component.get("v.recordId")  
             
        });
        saveAction.setCallback(this, function(response) {
            var state = response.getState();
            console.log('state'+state);
            if(state === "SUCCESS") {
                var resultsToast = $A.get("e.force:showToast");
                resultsToast.setParams({
                    "title": "Quote",
                    "message": "Quote Creation is Success."
                });
                $A.get("e.force:closeQuickAction").fire();
                resultsToast.fire();
                $A.get("e.force:refreshView").fire();
            }
            else if (state === "ERROR") {
                var errors = response.getError();
                if (errors) {
                    if (errors[0] && errors[0].message) {
                        console.log("Error message: " + 
                                    errors[0].message);
                    }
                } else {
                    console.log("Unknown error");
                }
            } 
        });
        console.log('En Quier action ');
        $A.enqueueAction(saveAction);      
        
    },
    
    handleCancel: function(component, event, helper) {
        $A.get("e.force:closeQuickAction").fire();
    }
})



Apex:

public class QuickQuote {
    @AuraEnabled
    public static boolean saveQuote(Quote newQuote, Id oppId) {
        system.debug('newQuote'+newQuote);
        newQuote.OpportunityId = oppId;
        try{
            insert newQuote ; 
            return true ;
    }catch(Exception e){
         if (true) {  throw new AuraHandledException(e.getMessage());
         }
           return false ;     
        }       
    }   
}

 
  • February 20, 2020
  • Like
  • 0
Trying to test my first component for pulling quote line items into a VF email template. Any help greatly appreciated! 
VF Component:
<apex:component access="global" controller="SortedLineItemsController">
<apex:attribute name="value" type="Quote" assignTo="{!quote}" description="TODO: Describe me"/>

<apex:repeat var="li" value="{!sorted}">
<tr>
<td>{!li.Part_Name__c}</td>
<td>{!li.Technology_Pick__c}</td>
<td>{!li.Rev__c}</td>
<td>{!li.Material__c}</td>
<td>{!li.Description_Summary__c}</td>
<td>${!li.UnitPrice}</td>
<td>{!li.Quantity}</td>
<td>${!li.TotalPrice}</td>
</tr>
</apex:repeat>

<!-- Needed to work around limitation that the standard controller cannot "see"
the linkage between the value attribute and the opportunity property -->
<apex:variable var="oli" value="{!value.QuoteLineItems}" rendered="false">
{!oli.Part_Name__c}
{!oli.Technology_Pick__c}
{!oli.Rev__c}
{!oli.Material__c}
{!oli.Description_Summary__c}
{!oli.UnitPrice}
{!oli.Quantity}
{!oli.TotalPrice}
</apex:variable>
</apex:component
Apex Controller:
public class SortedLineItemsController {
    public Quote quote { get; set; }
    
    public QuoteLineItem[] getSorted() {
        if (quote == null || quote.quoteLineItems== null) {
            return null;
        }
        
        
        QuoteLineItem[] result = new QuoteLineItem[1];
        for (QuoteLineItem item : Quote.quoteLineItems) {
            result.add(0, item);
        }
        
        return result;
   }
}

​​​​​​​