0

I have a requirement where I need to set the defaultFieldValues dynamically (both field name & value). How can I achieve that?

var createRecordEvent = $A.get('e.force:createRecord');
if ( createRecordEvent ) {
    createRecordEvent.setParams({
        'entityApiName': 'Account',
        'defaultFieldValues': {
            'Name' : 'John',
            'XYZ__C' : '123',
        }
    });
    createRecordEvent.fire();
}
  • What have you tried so far? – Jayant Das Jun 13 '19 at 13:12
  • u r values what of type of format like collection(sobject)/Map? – sdandamud1 Jun 13 '19 at 13:34
  • am getting the values from apex as Map<String,String> – SUresh Shettigar Jun 13 '19 at 13:36
  • @JayantDas - i tired by passing as createRecordEvent.setParams({ varJSON}) varJSON =dynamical values from apex. – SUresh Shettigar Jun 13 '19 at 13:38
  • can you post the structure after use this JSON.stringify(your value of Map<String,String) ? – sdandamud1 Jun 13 '19 at 14:23
1

You can declare accounts as object. You can replace accounts values from your mapped object.

var accounts={ Name: 'John', XYZ__C : '123'};
var createRecordEvent = $A.get('e.force:createRecord');
if ( createRecordEvent ) {
    createRecordEvent.setParams({
        'entityApiName': 'Account',
        'defaultFieldValues': accounts
    });
    createRecordEvent.fire();
}
  • yea i followed the same ,its worked.thank you all. – SUresh Shettigar Jun 19 '19 at 9:16

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.