Everyone!
I'm currently practicing LWC.
I made an LWC1 that will create a new order (Order Object). And also created a different LWC2 to add product to the order created. Sadly, I can't add a new product since I'm not sure on how to get the record id (of the created id) of LWC1 and use it in LWC2. (If I'll combine the 2 LWCs, the LWC will actually run perfectly. I just wanted to try if it is possible to run the LWCs separately).
Please see below for the codes:
Please see below for the codes (partial only):
LWC1 (Create New Order):
handleSuccess(event) {
this.orderCreated = true;
if (this.orderCreated) {
getRecordId()
.then(result => {
this.recordId = result;
})
}
event = new ShowToastEvent({
title: 'Success!',
message: 'Order Created',
});
this.dispatchEvent(event);
}
LWC2 (Add Product):
addProduct(event) {
this.getRecordId = event.detail;
if (this.recordId == null || this.recordId == '') {
alert('Please create a record first');