7

I have a Lightning Web Component on my contact detail page. It displays the address. I have used \n while displaying different fields of address. When I deployed the code to another sandbox, the \n did not work. I verified the code and found it to be the same. I tried using '\r\n', '<br>' and '&nbsp' but nothing worked. How is it working in one sandbox and not working in other sandbox? Please guide. Thank You!

Please find the code and screenshots below.

Code for adding address in data

NOTE: The data is flattened because data is returned using a wrapper class.

//get data from apex class and flatten it
    @wire(getAddress, { id: '$recordId' }) wired(result) {
        //set the wired property for refreshing datatable
        this.refreshTable = result;
        if (result.data) {
            //create an array
            let preparedAddresses = [];
            //for each row of data, put a row in var named address
            result.data.forEach(address => {
            //create a row and add data in it
            let preparedAddress = {};

            //Address construction
            preparedAddress.Address_custom = (address.AddressID.Building_Name__c ? address.AddressID.Building_Name__c : '') +''+ (address.AddressID.Street_Address__c ? '\n'+address.AddressID.Street_Address__c : '') +''+ (address.AddressID.Street_Address_1__c ? '\n'+address.AddressID.Street_Address_1__c : '') +''+ (address.AddressID.PO_Box_Number__c ? '\nPO Box: '+address.AddressID.PO_Box_Number__c : '') +''+ (address.AddressID.City__c ? '\n'+address.AddressID.City__c : '') +''+ (address.AddressID.AP_State_Code__r ? '\n'+address.AddressID.AP_State_Code__r.Name : '') +' '+ (address.AddressID.Postal_Code__c ? ''+address.AddressID.Postal_Code__c : '') +''+ (address.AddressID.AP_Country_Code__r ? '\n'+address.AddressID.AP_Country_Code__r.Name : '');

            //push the row in array
            preparedAddresses.push(preparedAddress);
            });
            //assign the array to @track variable
            this.addresses = preparedAddresses;
        }
    }

HTML FILE

<!-- datatable -->
        <div class="eighty-percent slds-table_bordered slds-table_striped slds-scrollable slds-m-around_medium">
            <lightning-datatable key-field="CRId" data={addresses} columns={columns} onrowaction={handleRowActions}
                >
            </lightning-datatable>
        </div>

Screenshot after development

sc1

Screenshot after deployment to other sandbox

sc2

10
  • 1
    Are you testing it on the same kind of browser? Both the sandbox have same API version? How are you opening the component? Jun 8 '20 at 12:14
  • 2
    Perhaps one sandbox is on Spring 20 whilst the other is on Summer 20? There could be differences in this upcoming release that are causing the difference in behavior. Which sandbox is which version?
    – sfdcfox
    Jun 8 '20 at 12:24
  • 1
    @sanketkumar @sfdcfox Thankyou for the response. I verified the versions of both the sandboxes. The sandbox where \n works has API version 48 and the sandbox where \n does not work has API version 49. What should be done in this case? How do I apply \n to the sandbox with version 49? Please guide. Thanks again!
    – Koustubh
    Jun 8 '20 at 14:17
  • 1
    @sfdcfox '\n' is not working in summer 20 but it is working in spring 20. I read the release notes of summer 20 but did not find anything related to newline character.
    – Koustubh
    Jun 10 '20 at 8:16
  • 6
    I'm going to ask around for you. Sit tight.
    – sfdcfox
    Jun 10 '20 at 13:00
5

This was a change in Summer'20 -- https://docs.releasenotes.salesforce.com/en-us/summer20/release-notes/rn_lwc_components.htm

2
  • 1
    See also this tweet.
    – sfdcfox
    Jun 24 '20 at 21:21
  • @sfdcfox Thanks a lot! Wrap text shows the address properly. Is there a way to default the column action to wrap text instead of clip text?
    – Koustubh
    Jun 25 '20 at 5:48

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.