Sample Code:
String timestamp = '2023-08-07T14:53:49Z';
timestamp = timestamp.replace('T', ' ');
System.debug('Datetime ==> '+DateTime.valueOf(timestamp));
Screenshot:
Sample Code:
String timestamp = '2023-08-07T14:53:49Z';
timestamp = timestamp.replace('T', ' ');
System.debug('Datetime ==> '+DateTime.valueOf(timestamp));
Screenshot:
This post explains how to open the popup using Lightning web components (LWC).
LWCModal Component
lwcmodal.html
<template>
<lightning-modal-header label={label}></lightning-modal-header>
<lightning-modal-body>
<lightning-datatable key-field="id" data={conData} columns={columns}>
</lightning-datatable>
</lightning-modal-body>
<lightning-modal-footer>
<lightning-button variant="brand" label="OK" onclick={handleOkay}></lightning-button>
</lightning-modal-footer>
</template>
lwcmodal.js
import { api } from 'lwc';
import LightningModal from 'lightning/modal';
export default class Lwcmodal extends LightningModal {
@api conData;
@api columns;
@api label;
handleOkay(event) {
this.close('okay');
}
}
<template>
<lightning-card variant="Narrow">
<p class="slds-p-horizontal_small">When clicking the button it opens the dynamic modal.<br/>
<lightning-button variant="brand" onclick={handleContactData} label="Show Contact Data"></lightning-button>
</p>
</lightning-card>
</template>
dynamicmodal.jsimport { LightningElement } from 'lwc';
import MyModal from "c/lwcmodal";
import getContacts from '@salesforce/apex/LWCExampleController.getContacts';
export default class Dynamicmodal extends LightningElement {
consData;
columns = [
{ label: 'First Name', fieldName: 'FirstName', type:'text' },
{ label: 'Last Name', fieldName: 'LastName', type: 'text' },
{ label: 'Name', fieldName: 'Name', type: 'text' },
{ label: 'Email', fieldName: 'Email', type: 'email' },
];
connectedCallback() {
getContacts().then(res => {
console.log('res => ', res);
this.consData = res;
})
.catch(error => {
console.log('error => ', error);
});
}
async handleContactData() {
const result = await MyModal.open({
label: 'Contact Data',
size: 'large',
columns: [...this.columns],
conData : [...this.consData]
});
// if modal closed with X button, promise returns result = 'undefined'
// if modal closed with OK button, promise returns result = 'okay'
console.log('result ==> ',result);
}
}
Apex class
This post explain how to convet to XML string to Blob and you can sent blob to servers.
convertXMLStringToblob = (xmlstring) => {
// Convert xml string to base64data
let xmlval = new DOMParser().parseFromString(xmlstring, 'application/xml');
let base64Data = window.btoa((new XMLSerializer()).serializeToString(xmlval));
// Convert base64data to blob
const byteCharacters = window.atob(base64Data);
const byteNumbers = new Array(byteCharacters.length);
for (let i = 0; i < byteCharacters.length; i++) {
byteNumbers[i] = byteCharacters.charCodeAt(i);
}
const byteArray = new Uint8Array(byteNumbers);
return new Blob([byteArray], {type:'application/xml'});
}
Sample file