I'm trying to fill <aura:attribute name="selectedQuotation" type="salesTool.Quotation__c" />
in any way that could works
Filling it with default value compile (means i can save the file)
default="{ 'sobjectType': 'salesTool__Quotation__c',
'Name': 'Test',
'Id':'',
'salesTool__Contact__c':'',
'salesTool__Package__c':'',
'salesTool__Signed__c':false,
'salesTool__Site__c':''
}"
But a "Uncaught Error: ComponentDef Config required for registration" Error is raised in browser logs at runtime.
The folloing demonstration example works well for me :
<aura:attribute name="newExpense" type="salesTool.Expense__c"
default="{ 'sobjectType': 'salesTool__Expense__c',
'Name': '',
'salesTool__Amount__c': 0,
'salesTool__Client__c': '',
'salesTool__Date__c': '',
'salesTool__Reimbursed__c': false
}"/>
But my case is different in a way i use lookupFields and not only literals.
Filling it with an instance of myCustomObject through application event result in an other error.
As it seems my aura:attribute is empty at the initialisation of the component, the variable last in a aura source code is null and cause error.
if (value.auraType === "Component" || !value.isLiteral()) {
var last = component.lastRenderedValue;
if (last !== value) {
var referenceNode = **last**.getReferenceNode();
If somebody have some better experience of lightning, I would appreciate some help 😉
Best Answer
You can set a the value of a Lookup field with the Id of the record it references.
For example, if you have a Contact object you can specify a default for the Account lookup, by specifying an Id string for the AccountId field.
You could also leave it blank and then set it in your JavaScript before calling to your Apex controller.
And, prior to enqueueing the action set the value explicitly.
Or, you could leave it blank altogether and set it in your Apex controller: