But when I select a Date, the following error appears:Uncaught Error in $A.getCallback() [Cannot read property 'SBQQ__EndDate__c' of null]<aura:component implements="force:lightningQuickActionWithoutHeader,force:hasRecordId" access="global">
<!-- Define Attribute-->
<aura:attribute name="newQuote" type="Object"/>
<aura:attribute name="simpleNewQuote" type="Object" default="{'sobjectType':'SBQQ__Quote__c', 'SBQQ__EndDate__c':2018-01-01}"/>
<aura:attribute name="newQuoteError" type="String"/>
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<force:recordData aura:id="QuoteRecordCreator"
layoutType="FULL"
targetRecord="{!v.newQuote}"
targetFields="{!v.simpleNewQuote}"
targetError="{!v.newQuoteError}" />
<div class="slds-modal__header">
<h2 class="slds-text-heading--medium">New Quote</h2>
</div>
<!-- Display the new quote form -->
<div class="slds-form_stacked">
<lightning:input aura:id="QuoteField" type="date" name="Notes" label="Offer end date"
value="{!v.simpleNewQuote.SBQQ__EndDate__c}"/>
<lightning:textarea aura:id="QuoteField" name="Notes" label="Additional notes"
value="{!v.simpleNewQuote.SBQQ__Notes__c}"/>
<lightning:button label="Create Quote" onclick="{!c.handleSaveQuote}"
variant="brand" class="slds-m-top_medium"/>
</div>
</aura:component>
throws at https://hum.lightning.force.com/auraFW/javascript/1bO4dJePbDnoI-_VdhdsEQ/aura_proddebug.js:31064:9. Caused by: Error in $A.getCallback() [Cannot read property 'SBQQ__EndDate__c' of null]
AttributeSet.set()@https://hum.lightning.force.com/auraFW/javascript/1bO4dJePbDnoI-_VdhdsEQ/aura_proddebug.js:22401:12
componentConstructor.Component.set()@https://hum.lightning.force.com/auraFW/javascript/1bO4dJePbDnoI-_VdhdsEQ/aura_proddebug.js:16854:37
PropertyReferenceValue.set()@https://hum.lightning.force.com/auraFW/javascript/1bO4dJePbDnoI-_VdhdsEQ/aura_proddebug.js:15155:41
AttributeSet.set()@https://hum.lightning.force.com/auraFW/javascript/1bO4dJePbDnoI-_VdhdsEQ/aura_proddebug.js:22402:17
componentConstructor.Component.set()@https://hum.lightning.force.com/auraFW/javascript/1bO4dJePbDnoI-_VdhdsEQ/aura_proddebug.js:16854:37
Object.onNodeValueChange()@https://hum.lightning.force.com/components/lightning/input.js:319:27
Object.eval [as input]()@https://hum.lightning.force.com/libraries/lightning/domLibrary/dom.js:218:33
runSyntheticEvent()@https://hum.lightning.force.com/libraries/lightning/domLibrary/dom.js:128:27
HTMLInputElement.eventListener()@https://hum.lightning.force.com/libraries/lightning/domLibrary/dom.js:131:24Can anyone tell me how to solve it please?
Hi, Try this code in your JS controller:
Let me know if it helps.Thanks!({
doInit: function(component, event, helper) {
// Prepare a new record from template
component.find("QuoteRecordCreator").getNewRecord(
"SBQQ_Quote__c", // sObject type (objectApiName)
null, // recordTypeId
false, // skip cache?
$A.getCallback(function() {
var rec = component.get("v.newQuote");
var error = component.get("v.newQuoteError");
if(error || (rec === null)) {
console.log("Error initializing record template: " + error);
return;
}
console.log("Record template initialized: " + rec.sobjectType);
})
);
},
handleSaveQuote: function(component, event, helper) {
component.set("v.simpleNewQuote.SBQQ_Opportunity2__c", component.get("v.recordId"));
component.set("v.simpleNewQuote.SBQQ_LineItemsGrouped__c", true);
component.set("v.simpleNewQuote.SBQQ_Primary__c", true);
component.find("QuoteRecordCreator").saveRecord(function(saveResult) {
if (saveResult.state === "SUCCESS" || saveResult.state === "DRAFT") {
// record is saved successfully
var resultsToast = $A.get("e.force:showToast");
resultsToast.setParams({
"type": 'success',
"title": "Saved",
"message": "The new quote has been created."
});
resultsToast.fire();
helper.navigateTo(component, saveResult.recordId);
} else if (saveResult.state === "INCOMPLETE") {
// handle the incomplete state
console.log("User is offline, device doesn't support drafts.");
} else if (saveResult.state === "ERROR") {
// handle the error state
var errors = response.getError();
var resultsToast = $A.get("e.force:showToast");
resultsToast.setParams({
"type":"error",
"title": "Error!",
"message": errors
//"message": "The new quote has an error." + saveResult.state + ", error: " + JSON.stringify(saveResult.error)
});
resultsToast.fire();
helper.navigateTo(component, saveResult.recordId);
console.log('Problem saving contact, error: ' + JSON.stringify(saveResult.error));
} else {
console.log('Unknown problem, state: ' + saveResult.state + ', error: ' + JSON.stringify(saveResult.error));
}
});
}
})