I have a requirement to build a custom component for Customer Community to create a new case. On the form I have a lookup field to a custom object that doesn't want to work. Are lookups to custom objects suppose to work in communities? Here's a simplified version of my code.
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
<aura:attribute name="Case" type="Case" />
<aura:attribute name="newCase" type="Object" />
<aura:attribute name="simpleNewCase" type="Object" />
<aura:attribute name="newCaseError" type="String" />
<force:recordData aura:id="caseRecordCreator"
fields="Location__c,LocationTest__c,Number_of_Required_Extensions__c,Primary_Use_for_Numbers__c,Extension_End_Range__c"
targetRecord="{!v.newCase}"
targetFields="{!v.simpleNewCase}"
targetError="{!v.newCaseError}" />
<!-- First we initialize the form -->
<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
<lightning:recordEditForm objectApiName="Case"
onsubmit="{!c.handleSaveCase}" >
<lightning:inputField fieldName="Location__c" />
<lightning:inputField fieldName="OwnerId" />
<lightning:inputField fieldName="LocationTest__c" />
<lightning:inputField fieldName="ContactId" />
<lightning:input label="Input" value="{!v.case.LocationTest__c}"/>
</lightning:recordEditForm>
</aura:component>
({
doInit : function(component, event, helper) {
//Standard way to load a record template using Lightning Data Service
component.find("caseRecordCreator").getNewRecord(
"Case",
"0122a0000008c9lAAA",
false,
$A.getCallback(function(){
var rec = component.get("v.newCase");
var error = component.get("v.newCaseError");
if(error || (rec === null)){
console.log("Error initializing record template: " + error);
}else{
console.log("Record template initialized" + rec.sobjectType);
}
})
);
},
handleSaveCase : function(component, event, helper){
//This is how we link the new Contact with the actual Account Id
//component.set("v.simpleNewCase.AccountId", component.get("v.simpleUser.AccountId"));
//alert("{!v.simpleUser.AccountId}");
//component.set("v.simpleNewCase.ContactId", component.get("v.simpleUser.ContactId"));
//Standard way to save a record using Lightning Data Service
component.find("caseRecordCreator").saveRecord(function(saveResult){
if(saveResult.state === "SUCCESS" || saveResult.state === "DRAFT"){
//resultToast is a pop-up window that show messages.
var resultsToast = $A.get("e.force:showToast");
resultsToast.setParams({
"title" : "Case saved",
"message" : "The new case was created",
"type" : "success"
});
$A.get("e.force:closeQuickAction").fire();
resultsToast.fire();
$A.get("e.force:refreshView").fire();
}else if(saveResult.state === "INCOMPLETE"){
console.log("User is offline, device doesn't support drafts.");
}else if(saveResult.state === "ERROR"){
console.log("Problem saving case, error" + JSON.stringify(saveResult.error));
}else{
console.log("Unknown problem, state: " + saveResult.state + ', error: ' + JSON.stringify(saveResult.error));
}
});
}})
Why isn't the Location lookup showing any values?