2

This functionality went live a couple of months ago and everything was working fine until recent release.

When user selects record type and click on Next it would run the below function.

handleRTselection : function(component, event, helper) {
    if(component.get("v.recTypeId") !== undefined){
        var createRecordEvent = $A.get("e.force:createRecord");
        var recId = component.get("v.recordId");
            console.log(recId);
            console.log(recId.startsWith('500'));
            console.log(component.get("v.recTypeId"));
        if(recId.startsWith('500')){
            createRecordEvent.setParams({
                "entityApiName": "Milestone1_Task__c",
                "defaultFieldValues": {
                    'RecordTypeId' : component.get("v.recTypeId"),
                    'Case__c' : recId
                }
            });
        }
        else{
            console.log(component.get("v.recTypeId"));
            createRecordEvent.setParams({
                "entityApiName": "Milestone1_Task__c",
                "defaultFieldValues": {
                    'RecordTypeId' : component.get("v.recTypeId"),
                    'Project_Milestone__c' : recId
                }
            });
        }
        createRecordEvent.fire();
        component.set("v.rtPopup",false);
    }
 }

record type selection

The layout which is being shown is correct but the record type label on the top is showing default record type on the users profile irrespective of what the user has chosen for.

enter image description here

  • Could you show the code where force:createRecord is actually being used? – Brian Miller Jul 9 at 7:34
  • updated the post – Venky Jul 9 at 7:48
4

Found a possible solution. Recordtypeid should not be in default values, it should be outside.

createRecordEvent.setParams({
    "entityApiName": "Milestone1_Task__c",
    'recordTypeId' : component.get("v.recTypeId"),
    "defaultFieldValues": {
        'Case__c' : recId
     }
});
2

Note that the recordTypeId field name is case sensitive so it should be indeed written as "recordTypeId" not "RecordTypeId"

Found this mentioned in the answer to this post in developer forum.

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.