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 ' '
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>
\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!'\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.