0

I have created a component, that consist of 2 checkboxes, and 4 fields (3 currency fields, 1 number), and a button that save this into a related record.

I have seen some similar questions asked before like this one, and apparently the fields number was an issue before and was "supposed" to be fixed, but clearly not.

I am wondering what could be a work around for this problem, as in the sandbox i can set the field using

component.set("v.simplequote.Term_Weeks__c",Term_Weeks);

but in production this value is always undefiend

Component:

<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId, home:availableForDesktop, flexipage:availableForAllPageTypes" access="global" >
<aura:attribute name="recordId" type="Id" /> 
<aura:attribute name="quote" type="Object"/>
<aura:attribute name="simplequote" type="Object"/>
<aura:attribute name="quoteError" type="String"/>   
<!-- 
    SALESFORCE BUG DOESNT WORK IF THE FIELD IS TYPE NUMBER (SALESFORCE FIELD IN THE OBJECT), BUT IT WORKS WITH CURRENCY
    THIS IS WHY I AM SETTING A FIELD INSTEAD OF USING DIRECTLY THE v.simplequote.Term_Weeks__c 
 -->
<aura:attribute name="termweeks" type="Integer"/>   
<aura:attribute name="test" type="Boolean" default="false"/>   
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<force:recordData aura:id="loanCalcCreator" 
                  layoutType="FULL"
                  targetRecord="{!v.quote}"
                  targetFields="{!v.simplequote}"
                  targetError="{!v.quoteError}"
                   />
<!-- Display the quote form -->
<div class="newquote">
    <lightning:card class="slds-p-horizontal_medium" iconName="standard:bot" title="Loan Calculator">  
        <div class="slds-p-horizontal--small">
            <lightning:layout multipleRows="true">
                <lightning:layoutItem size="6">
                        <lightning:input 
                        aura:id="mainquote"
                        name="mainquote"
                        label="Main Quote?"
                        type="toggle"
                        messageToggleActive="Yes"
                        messageToggleInactive="No"
                        checked="{!v.simplequote.Is_this_main_quote__c}"
                         />
                </lightning:layoutItem>
                <lightning:layoutItem size="6">
                        <lightning:input 
                        aura:id="spoken"
                        name="spoken"
                        label="Spoke with client?"
                        type="toggle"
                        messageToggleActive="Yes"
                        messageToggleInactive="No" 
                        checked="{!v.simplequote.Spoken_with_Client__c}"
                        />
                </lightning:layoutItem>
                <lightning:layoutItem size="6" class="slds-p-right_x-small">
                    <lightning:input aura:id="msales" onchange="{!c.loanCalc}" label="Monthly sales" value="{!v.simplequote.Monthly_sales__c}"/>
                </lightning:layoutItem>
                <lightning:layoutItem size="6">
                    <lightning:input aura:id="frate" onchange="{!c.loanCalc}" label="Facility rate" value="{!v.simplequote.Facility_rate__c}"/>
                </lightning:layoutItem>
                <lightning:layoutItem size="6" class="slds-p-right_x-small">
                    <lightning:input aura:id="famount" onchange="{!c.loanCalc}" label="Facility Amount" value="{!v.simplequote.Facility_Amount__c}"/>
                </lightning:layoutItem>
                <lightning:layoutItem size="6">
                    <lightning:input type="number" step="1" aura:id="tweeks" onchange="{!c.loanCalc}" label="Term Weeks" value="{!v.termweeks}"/>
                </lightning:layoutItem>
            </lightning:layout>
        </div>

        <lightning:layout multipleRows="true" class="slds-p-vertical_x-small">
            <lightning:layoutItem size="6">
                <span class="slds-form-element__label">Facility Fee</span>
                <br/>
                <div class="slds-form-element__control">
                    <div class="slds-form-element__static">$ {!v.simplequote.Facility_Fee__c}</div>
                </div>    
            </lightning:layoutItem>  
            <lightning:layoutItem size="6">
                <span class="slds-form-element__label">LMOR</span>
                <br/>
                <div class="slds-form-element__control">
                    <div class="slds-form-element__static">{!v.simplequote.LMOR__c} %</div>
                </div>    
            </lightning:layoutItem> 


            <lightning:layoutItem size="6">
                <span class="slds-form-element__label">Facility Sum</span>
                <br/>
                <div class="slds-form-element__control">
                    <div class="slds-form-element__static">$ {!v.simplequote.Facility_Sum__c}</div>
                </div>    
            </lightning:layoutItem>  
            <lightning:layoutItem size="6">
                <span class="slds-form-element__label">Term In Weeks</span>
                <br/>
                <div class="slds-form-element__control">
                    <div class="slds-form-element__static">{!v.simplequote.Term_In_Weeks__c}</div>
                </div>    
            </lightning:layoutItem> 


            <lightning:layoutItem size="6">
                <span class="slds-form-element__label">Weekly Repayment</span>
                <br/>
                <div class="slds-form-element__control">
                    <div class="slds-form-element__static">$ {!v.simplequote.Weekly_Repayment__c}</div>
                </div>    
            </lightning:layoutItem>  
            <lightning:layoutItem size="6">
                <span class="slds-form-element__label">Repayment Amount</span>
                <br/>
                <div class="slds-form-element__control">
                    <div class="slds-form-element__static">{!v.simplequote.Repayment_Amount__c}</div>
                </div>    
            </lightning:layoutItem>             
        </lightning:layout>

        <br/>
        <lightning:button label="Save Quote" variant="brand" onclick="{!c.handleSaveQuote}"/>

    </lightning:card>
</div>

<!-- Display Lightning Data Service errors -->
<aura:if isTrue="{!not(empty(v.quoteError))}">
    <div class="recordError">
        {!v.quoteError}</div>
</aura:if>    

my controller:

({
    loanCalc: function(component, event, helper) { 
        var Term_Weeks = component.get("v.termweeks");
        if (!helper.empty(Term_Weeks,false)) {
            Term_Weeks = parseFloat(Term_Weeks);
            component.set("v.simplequote.Term_Weeks__c",Term_Weeks);

            console.log('Term_Weeks: ' + Term_Weeks );
            console.log('component val: ' + component.get("v.simplequote.Term_Weeks__c"));

What is extremly concerning is my sandbox looks like this

enter image description here

But production

enter image description here PS: the sample in the sandbox works properly

  • Is the API Version on your sandbox the same as Production? – Lightning Evangelist Jul 26 '18 at 11:35
  • Component is in 43, sandbox org (following this instructions: help.salesforce.com/articleView?id=000199268&type=1) shows 43. then production the component is also 43, salesforce org after generating the enterprise wsdl shows: Salesforce.com Enterprise Web Services API Version 43.0. so they are exactly the same right? – manza Jul 26 '18 at 22:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.