0

I just completed the Aura Components Basics - Connect to Salesforce with Server-Side Controllers. Wrote the code and passed the text. But upon testing it in the App Preview, I get insert errors. The nature of this insert error is unclear. The apex code:

public with sharing class CampingListController {
    
    @AuraEnabled
    public static List<Camping_Item__c> getItems() {
        return [SELECT id,name,price__c,Quantity__c,Packed__c
               FROM Camping_Item__c];
    }
    
    @AuraEnabled
    public static Camping_Item__c saveItem (Camping_Item__c item) {
        upsert item;
        return item;
    }
}

And the corresponding error:

14:33:41:004 FATAL_ERROR System.DmlException: Upsert failed. First exception on row 0; first error: INVALID_FIELD_FOR_INSERT_UPDATE, un12331__Camping_Item__c: bad field names on insert/update call: Price__c, Packed__c, Quantity__c: [Price__c, Packed__c, Quantity__c]

I have the Camping_Item defined in the Object Manager.

1 Answer 1

2

Your org has a namespace (un12331), so you need to include the namespace for each field: un12331__Packed__c,un12331__Price__c,un12331__Quantity__c. Standard fields don't need the namespace, such as Name or OwnerId. It's probably a better idea to create a new Playground that doesn't have a namespace for trailheads that don't call for one, and reserve your namespaced org for trailheads that do.

0

You must log in to answer this question.

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