0

In my controller I populate a map with the record type id:

         ...
            String myrec = 
             GetRecordType.getDefaultRecordTypeID('Waste_Assessment__c');
            fields.put('rectypeid',myrec);
       }
    return fields;

then I fire a create event with e.force:createRecord

       var createWA = $A.get('e.force:createRecord');
        console.log('2rec type id: '+fields['rectypeid']);
        var recTYPEID = fields['rectypeid'];
        createWA.setParams({
            "entityApiName":"Waste_Assessment__c",
            "recordTypeId": recTYPEID,
            "defaultFieldValues":fields
        });
        createWA.fire();

the new record window appears but when I try to save I get:

No access to field rectypeid. Either the field was removed from the entity or access to this field was removed. enter image description here

What's going on ?

  • 1
    Do you receive the same error if you don't use the record type? Not sure but this could be related to this known issue. – Jayant Das Mar 21 at 19:32
  • I saw that before too, and yea I still get the message, which is weird because the message mentions my variable name. How could it know if I've commented it out of the setParams() list – SallyRothroat Mar 21 at 20:33
  • And yea I see the recordtypid in console.log() just fine. – SallyRothroat Mar 21 at 20:34
  • Ah i think it's because I am passing that same map to the default fields option! – SallyRothroat Mar 21 at 20:35
  • Are you able to resolve it? I am getting the same error. – sfdc rowdy Jun 26 at 12:00
1

Replace recordTypeId by RecordTypeId because its case sensitive :

createWA.setParams({ "entityApiName":"Waste_Assessment__c", "RecordTypeId": recTYPEID, "defaultFieldValues":fields });

0

I fixed this by removing the property that was causing the error:

    var createWA = $A.get('e.force:createRecord');
    console.log('2rec type id: '+fields['rectypeid']);
    var recTYPEID = fields['rectypeid'];

   //remove prop
   delete fields['rectypeid'];       


    createWA.setParams({
        "entityApiName":"Waste_Assessment__c",
        "recordTypeId": recTYPEID,
        "defaultFieldValues":fields
    });
    createWA.fire();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.