0

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 dev org

Element inspection from package: enter image description here

--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.

6
  • I should mention that both of the fields which don't show up, SearchableClientNames__c and SearchableAdversePartyNames__c are on the default details page and can properly be edited there.
    – Chris
    Jan 26, 2023 at 22:27
  • What is SEARCHABLE_ADVERSE_PARTIES_FIELD? I'm guessing the same as you, in that the namespaces aren't there in subscriber org
    – Nick C
    Jan 27, 2023 at 0:34
  • I added the field name import statements for SEARCHABLE_ADVERSE_PARTIES_FIELD and SEARCHABLE_CLIENTS_FIELD. They're both just TextAreas.
    – Chris
    Jan 27, 2023 at 0:52
  • Doesn't the field-name need the field api name, not the imported field object? ie. couldn't you use SEARCHABLE_ADVERSE_PARTIES_FIELD.fieldApiName?
    – Nick C
    Jan 27, 2023 at 2:16
  • Did you check for field level permissions on those fields in the org you've installed the package? Jan 27, 2023 at 2:26

1 Answer 1

0

At this point I'm just speculating, but it might be that the user in the org where you have the package installed does not have access to the fields themselves. From the documentation on the lightning-record-edit-form:

This component also takes care of field-level security and sharing for you, so users see only the data they have access to.

3
  • I've checked the field-level permissions a couple times, but I'm starting to suspect this is the issue. I'm somewhat new to permissions stuff so let me know if there's something I'm missing. I've checked the Field Accessibility section of Setup and both fields used in the edit form are editable by all profiles. I've ensured that the fields are on the detail page and that I can edit them (although my profile is sys admin, so that could be misleading). I've also created a permissions set that gives read/edit permissions to all fields on Intake__c and assigned it to my user. No luck :/
    – Chris
    Jan 27, 2023 at 3:44
  • As additional confirmation, I created a new test user and cloned the Standard User profile. The only thing I changed in the profile was the ability to read, create, edit, and delete the fields in the Intake object. From that new user I can see and edit the two fields on the Details page but they still don't show in the record edit form
    – Chris
    Jan 27, 2023 at 4:09
  • Instead of using a getter method to return the imported variable, assign it to a variable and return the variable instead. Maybe there's something happening in the translation layer when the component is packaged. If that doesn't work maybe you'll be better off opening a case with Salesforce. Jan 27, 2023 at 17:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .