In this post we are going to learn about How to Create Quote and QuoteLineItem From Opportunity in Lightning Web Component – LWC Salesforce.
Quote Line Items are automatically created when the Quote is created from an Opportunity based on the Opportunity Products attached to that Opportunity. Creating a Quote from an Opportunity in Classic always results in Quote Line Items created but in Lightning for the same record it is possible that no Quote Line Items are created. To know more about Quote and QuoteLineItem, Click Here.
Create Lightning Web Component HTML
Step 1:- Create Lightning Web Component : createQuoteAndLineItemLwc.html
`
Quote
Quote Line Item
Add Quote Line Item
{indx}
Description:-
UnitPrice:-
Quantity:-
QuoteId:-
Product2Id:-
`
Create Lightning Web Component JavaScript
Step 2:- Create Lightning Web Component : createQuoteAndLineItemLwc.js
`import { LightningElement, track,api, wire } from 'lwc';
import { getRecord } from 'lightning/uiRecordApi';
import submitOptRecord from '@salesforce/apex/createQuoteAndLineItemLwcCtrl.submitOptRecord';
import getOpportunityList from '@salesforce/apex/createQuoteAndLineItemLwcCtrl.getOpportunityList';
import saveQuoteLineItem from '@salesforce/apex/createQuoteAndLineItemLwcCtrl.saveQuoteLineItem';
//import NAME_FIELD from '@salesforce/schema/QuoteLineItem.Name';
import Description_FIELD from '@salesforce/schema/QuoteLineItem.Description';
import UnitPrice_FIELD from '@salesforce/schema/QuoteLineItem.UnitPrice';
import Quantity_FIELD from '@salesforce/schema/QuoteLineItem.Quantity';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import {NavigationMixin} from 'lightning/navigation';
export default class CreateQuoteAndLineItemLwc extends NavigationMixin(LightningElement) {
In this post we are going to learn about How to Create Quote and QuoteLineItem From Opportunity in Lightning Web Component – LWC Salesforce.
Quote Line Items are automatically created when the Quote is created from an Opportunity based on the Opportunity Products attached to that Opportunity. Creating a Quote from an Opportunity in Classic always results in Quote Line Items created but in Lightning for the same record it is possible that no Quote Line Items are created. To know more about Quote and QuoteLineItem, Click Here.
👉 To get source code live demo link, Click Here.
Create Lightning Web Component HTML Step 1:- Create Lightning Web Component : createQuoteAndLineItemLwc.html
`
Quote
Quote Line Item
Description:-
UnitPrice:-
Quantity:-
Product2Id:-
`
Create Lightning Web Component JavaScript Step 2:- Create Lightning Web Component : createQuoteAndLineItemLwc.js
`import { LightningElement, track,api, wire } from 'lwc'; import { getRecord } from 'lightning/uiRecordApi'; import submitOptRecord from '@salesforce/apex/createQuoteAndLineItemLwcCtrl.submitOptRecord'; import getOpportunityList from '@salesforce/apex/createQuoteAndLineItemLwcCtrl.getOpportunityList'; import saveQuoteLineItem from '@salesforce/apex/createQuoteAndLineItemLwcCtrl.saveQuoteLineItem';
//import NAME_FIELD from '@salesforce/schema/QuoteLineItem.Name'; import Description_FIELD from '@salesforce/schema/QuoteLineItem.Description'; import UnitPrice_FIELD from '@salesforce/schema/QuoteLineItem.UnitPrice'; import Quantity_FIELD from '@salesforce/schema/QuoteLineItem.Quantity'; import { ShowToastEvent } from 'lightning/platformShowToastEvent'; import {NavigationMixin} from 'lightning/navigation';
export default class CreateQuoteAndLineItemLwc extends NavigationMixin(LightningElement) {
// @track name = NAME_FIELD; @track Description = Description_FIELD; @track UnitPrice = UnitPrice_FIELD; @track Quantity = Quantity_FIELD; @track quoteLineRecoreId; @track message; @track error; isLoaded = false;
//Start Quote
//Start Quote Line Item // acc qotLine = { Name : this.name,
Description : this.Description,
UnitPrice : this.UnitPrice, Quantity : this.Quantity, QuoteId : '', Product2Id :this.Product2Id,
PricebookEntryId :this.PricebookEntryId, key : '' }
}`
Create Lightning Web Component Meta XML Step 3:- Create Lightning Web Component : createQuoteAndLineItemLwc.js-meta.xml
`<?xml version="1.0" encoding="UTF-8"?>