2

I am trying to open a create new record layout from a lwc button, I need that this layout open with some field values prepopulated, I am using NavigationMixin Like this:

     this[NavigationMixin.Navigate]({
            type: 'standard__objectPage',
            attributes: {
                objectApiName: 'Retencion__c',
                actionName: 'new'
            },
            state : {
                useRecordTypeCheck: 1,
                nooverride: '1',
                defaultFieldValues: defValString,
                navigationLocation: 'RELATED_LIST'
            }
        });

When my defValString variable is something like :

defvalString = 'field1__C = value1,field2__c = value2,field3__c = value3,value4,value5';

The problem is when a value for field have a comma ',' the value is shorted in the first comma, I think this is for comma separated format, are there any way to allow comma ',' in my values?.

1 Answer 1

1

You can set value as JSON object.

        const defValString = encodeDefaultFieldValues({
            field1__C = value1,
            field2__c = value2,
            field3__c = 'value3,value4,value5'
        });

     this[NavigationMixin.Navigate]({
            type: 'standard__objectPage',
            attributes: {
                objectApiName: 'Retencion__c',
                actionName: 'new'
            },
            state : {
                useRecordTypeCheck: 1,
                nooverride: '1',
                defaultFieldValues: defValString,
                navigationLocation: 'RELATED_LIST'
            }
        });

Reference : https://developer.salesforce.com/docs/platform/lwc/guide/use-navigate-default.html

You must log in to answer this question.

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