I have a lightning record edit form which properly shows in my dev org, but when it's packaged, the lightning-input-fields no longer contain any html. I've confirmed that data is properly sent from the controller to the front end and that the field names have the package namespace on them. All of the console.log statments in the JS code show exactly what I expect. There's no error in fetchSearchableNamesFromContact, and the data from the backend is identical for both the dev org and the package.
From the screenshots at the end, you can see that the lightning-input-field containers are empty when I inspect the element through the packaged or, but show properly in the dev org.
My only guess is that there is a problem with the namespace of the field names in the lightning-input-fields, but I haven't found any other examples of this issue.
js:
...Other Imports...
import getSearchableNamesFromContact from '@salesforce/apex/CommonFinalizeIntakeController.getSearchableNamesFromContact';
import INTAKE_OBJECT from '@salesforce/schema/Intake__c';
import SEARCHABLE_ADVERSE_PARTIES_FIELD from '@salesforce/schema/Intake__c.SearchableAdversePartyNames__c';
import SEARCHABLE_CLIENT_NAMES_FIELD from '@salesforce/schema/Intake__c.SearchableClientNames__c';
...Other Code...
@wire(getSearchableNamesFromContact, {intakeId: '$recordId'})
fetchSearchableNamesFromContact({data, error}) {
if (error) {
alert('error in fetching searchable names');
console.log(error);
}
if (data) {
// These log statements properly show the data. User has permissions and data is sent to frontend
console.log('Adverse Names from Data: ' + data.adverseNames);
console.log('Client Names from Data: ' + data.clientNames);
console.log('Full data: ' + JSON.stringify(data, null, 4));
this.adverseNames = data.adverseNames;
this.clientNames = data.clientNames;
}
}
get searchableAdversePartiesField() {
// Shows namespaced field properly in package version
console.log('Searchable Adverse Names: ' + JSON.stringify(SEARCHABLE_ADVERSE_PARTIES_FIELD, null, 4));
return SEARCHABLE_ADVERSE_PARTIES_FIELD;
}
get searchableClientNamesField() {
console.log('Searchable Client Names: ' + JSON.stringify(SEARCHABLE_CLIENT_NAMES_FIELD, null, 4));
return SEARCHABLE_CLIENT_NAMES_FIELD;
}
lightning-record-edit-form HTML:
<lightning-record-edit-form
record-id={recordId}
density="comfy"
object-api-name="Intake__c"
onsuccess={handleLegalPartyUpdate}>
<lightning-layout>
<lightning-layout-item size="6">
<lightning-input-field required field-name={searchableAdversePartiesField} value={adverseNames}>
</lightning-input-field>
</lightning-layout-item>
<lightning-layout-item size="6">
<lightning-input-field required field-name={searchableClientNamesField} value={clientNames}>
</lightning-input-field>
</lightning-layout-item>
</lightning-layout>
<div class="slds-section slds-is-open slds-text-align_center">
<lightning-button class="slds-m-top_small" variant="brand" icon-name={legalPartyButtonIcon} type="submit" name="submit" label="Update legal party names"></lightning-button>
</div>
</lightning-record-edit-form>
Controller:
public class SearchableNames {
@AuraEnabled
public String clientNames;
@AuraEnabled
public String adverseNames;
}
@AuraEnabled(cacheable=true)
public static SearchableNames getSearchableNamesFromContact(Id intakeId) {
SearchableNames a = new SearchableNames();
Intake__c intake = [SELECT SearchableClientNames__c, Contact__r.SearchableClientNames__c, SearchableAdversePartyNames__c, Contact__r.SearchableAdversePartyNames__c, Contact__c FROM Intake__c WHERE Id = :intakeId];
//Default to intake searchable parties. Fetch Contact searchable parties if they don't exist.
a.clientNames = intake.SearchableClientNames__c == null ? intake.Contact__r.SearchableClientNames__c : intake.SearchableClientNames__c;
a.adverseNames = intake.SearchableAdversePartyNames__c == null ? intake.Contact__r.SearchableAdversePartyNames__c : intake.SearchableAdversePartyNames__c;
return a;
}
Element inspection from dev org:

Element inspection from package:

--Edit--
I've done some additional testing and sanity checking.
The console.log statement in get searchableAdversePartiesField shows what I expect. In the provider org it shows
{
"fieldApiName": "SearchableAdversePartyNames__c",
"objectApiName": "Intake__c"
}
While in the subscriber org it shows
{
"fieldApiName": "NS__SearchableAdversePartyNames__c",
"objectApiName": "NS__Intake__c"
}
where NS is the namespace of the package.
Based on the information in the lightning-record-edit-form documentation I tried importing the Intake__c object with my namespace, but that ran into this error on package installation:
Invalid module id "NS__Intake__c" for type "schema". Explicit use of namespace "NS" in file "finalizeIntake.js" is prohibited. Use default namespace "c" instead
I then tried using the default namespace (c) and ran into a new error on package installation:
finalizeIntake: Invalid reference c__Intake__c of type sobjectClass in file finalizeIntake.js: finalizeIntake: Invalid reference c__Intake__c of type sobjectClass in file finalizeIntake.js
I've also tried removing the getSearchableNamesFromContact wired function entirely and removing the value parameter from the lightning-input-field. The lightning input field containers are still empty when I inspect the elements. At this point I'm running out of ideas.
SearchableClientNames__candSearchableAdversePartyNames__care on the default details page and can properly be edited there.field-nameneed the field api name, not the imported field object? ie. couldn't you useSEARCHABLE_ADVERSE_PARTIES_FIELD.fieldApiName?