• krios demo
  • NEWBIE
  • 10 Points
  • Member since 2022

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 12
    Questions
  • 2
    Replies
I have a below scenario in LWC

I have iterated the Lightning button with Label "Schedule" using for:each in table. When there are three product then  buttons are generated for each product. when I click on first Schedule Button which index is "0" then when i create the record successfully and back to schedule for next product then previously clicked "Schedule" button which having "0" index should be disabled. 

HTML:

<template if:true={BaseTable}>
        <table>
            <thead>
                <tr style="text-align: center;">
<th style=" text-align: center; padding: 6px; border: 1px solid;" > Product Name </th>
<th style=" text-align: center; padding: 6px; border: 1px solid;" > Indent Quantity </th>
<th style=" text-align: center; padding: 6px; border: 1px solid;" > #### </th>
</tr>
     </thead>
            <tbody>
<template for:each={OrderItemData} for:item="item" for:index="index" >
<tr key={item.OrderId}>
<td style="text-align: center; padding: 6px; border: 1px solid;" > {item.Product2.Description} </td>
< td style="text-align: center; padding: 6px; border: 1px solid;" > {item.Quantity}</td>
<td style="padding: 6px; border: 1px solid"> 
      <lightning-button class="slds-m-left_xx-small slds-align_absolute-center" variant="brand" label="Schedule" title="ScheduleProduct" onclick={handleProductSchedule} data-id={item.Product2Id}
data-name={item.Product2.Description}                                          data-qty = {item.Quantity} disable = {DisableSchedule}               
data-index = {index}></lightning-button></td>
                    </tr>
                </template>
            </tbody>
        </table>
        </template>
=====================================================
JS:
handleProductSchedule(event) {
        this.productId = event.target.dataset.id;
        this.productName = event.target.dataset.name;
        this.productQty = event.target.dataset.qty;
        const buttonindex = event.target.dataset.index;
        event.target.disabled = true;
        
                
        this.BaseTable = false;
        this.ScheduleTable = true;
        this.CreateScheduleEnabled = false;
        
        console.log('Product ID:', this.productId);
        console.log('Product Name:', this.productName);
        console.log('Ordered Quantity :', this.productQty);
        console.log("Current Products Button Index ==> ", buttonindex)
    }
    handlebackfunction() {
        this.BaseTable = true;
        this.ScheduleTable = false;
    }

handleCreateSchedules(event){
        var schQty = 0;
        // Addition of all Schedule Quantity
        for(var i = 0; i < this.itemList.length; i++){
            schQty = parseInt(schQty) + parseInt(this.template.querySelector('[data-index = "' + i + '"]').value);
        }
        console.log('schQty', schQty);
        console.log('productQty', this.productQty);
        // checking schedule and indent Quantity same or not
        if (schQty == this.productQty) {
            console.log('Schedule Quantity Matches to Indent Quantity');
            const scheduleRecords = [];
            // Get all input data using querrySelectorAll
            const inputFields = this.template.querySelectorAll('[data-inputs]');
            let hasNullValues = false; 
            inputFields.forEach((input) => {
                const ProdName = this.productName;
                const ProdId = this.productId;
                const indexing = input.dataset.index;
                const fieldName = input.name;
                const fieldValue = input.value;
                // Check if Value of any field is Null
                if (fieldValue === null || fieldValue === '') {
                    this.showToast('Error', 'Please enter a value for ' + fieldName, 'error');
                    hasNullValues = true;
                } else {
                    const record = { indexing: indexing, ProdName: ProdName, ProdId: ProdId,  [fieldName]: fieldValue};
                    // Check if a record with the same indexing already exists in scheduleRecords
                    const existingRecord = scheduleRecords.find((rec) => rec.indexing === indexing);
                    if (existingRecord) {
                        // Merge the new field and value into the existing record
                        existingRecord[fieldName] = fieldValue;
                    } else {
                        scheduleRecords.push(record);
                    }
                }
            });
            if (!hasNullValues) {
                console.log('scheduleRecords', scheduleRecords);
            
                console.log("Schedule Creation Function before call");
                // Call Save Method from Apex
                SaveIndentSchedules({scheduleRecords, OrdId : this.recordId})
                .then(result =>{
                    console.log('Record Saved Successfully');
                    console.log(result);
                    this.showToast('Success', 'Schedule Records Saved Successfully...', 'success');
                    this.CreateScheduleEnabled = true;
                    this.refreshApex(this.wiredScheduleData);
                    
                })
                .catch(error => {
                    console.error('Error : Error Occured to Save The Records');
                })
            }
            
        } else if (schQty > this.productQty){
            this.showToast('Error', 'Schedule Quantity Exceeds Indent Quantity', 'Error');
        }
        else {
            this.showToast('Error', 'Schedule Quantity Does Not Match Indent Quantity', 'Error');
            console.error('Error: schQty does not equal productQty');
        }
    }

 

Hello,
I have a scenario. I have developed the LWC component in which Send Email button is present. When User Mark the Opportunity as "Indent" the modal popup appears on screen and when user click on Send Email Indented OppDetails are sent to receipients group Email Id. Here currently Organisation Wide Email Address Name will be displayed and email Id will be displayed as "From" address. 

I wanted to send the email by Opportunity Owner Name i.e. Opportunity Owner Name should be displayed as "From" Address. Below is my Apex Class Please Provide Solution asap.

public class DealWonVerification {
    
    public List<Opportunity> Oppdetails { get; private set; }
    public List<OpportunityLineItem> OppProds { get; private set; }
    public List<Order> OppOrders { get; private set; }
        
    @AuraEnabled(cacheable=true)  
    public static List<Opportunity> getOppDetails(String OppId){
        List<Opportunity> Oppdetails = [SELECT Id, Name, Owner.Name, Account.Name, CloseDate, Amount, StageName, Remark_by_SCM__c, Remarks_by_the_Sales__c 
                                        FROM Opportunity WHERE Id = :OppId];
        return Oppdetails;
    }
    
    @AuraEnabled(cacheable=true)
    public static List<OpportunityLineItem> getOpportunityLineItems(String OppId) {
        return [SELECT Id, Product2.Description, Quantity, UnitPrice, TotalPrice, Colour__c, Customization__c, Packing__c, New_Code_Required__c 
                FROM OpportunityLineItem WHERE OpportunityId = :OppId];
    }
    
    @AuraEnabled(cacheable=true)
    public static List<Order> getOrdersdetails(String OppId) {
        return [SELECT Id, OrderNumber, Quantity__c, Sales_Price__c, TotalAmount, EffectiveDate, Division_Code__c, EndDate 
                FROM Order WHERE OpportunityId = :OppId];
    }

    @AuraEnabled
    public static void SaveOppData(String OppId, String remarksbyscm, String remarksbysales){
        Opportunity Opp = [SELECT Id, Remark_by_SCM__c, Remarks_by_the_Sales__c FROM Opportunity WHERE Id = :OppId];
        
        Opp.Remark_by_SCM__c = remarksbyscm;
        Opp.Remarks_by_the_Sales__c = remarksbysales;
        update Opp;
    }
   
    @AuraEnabled
    public static void toSendEmailWithTemplate(String OppId){
        List<Order> OppOrder_s = [SELECT Id, OrderNumber, Quantity__c, Sales_Price__c, TotalAmount, EffectiveDate, Division_Code__c, EndDate 
                                  FROM Order WHERE OpportunityId = :OppId];
            
        List<Opportunity> OppOwner = [SELECT OwnerId, Owner.Email, Owner.Name FROM Opportunity WHERE Id = :OppId];
        String oppMail = OppOwner.isEmpty() ? null : OppOwner[0].OwnerId;
        String OppOwnerEmail = OppOwner.isEmpty() ? null : OppOwner[0].Owner.Email;
        System.debug('oppMail'+oppMail);
        System.debug('OppOwnerEmail'+OppOwnerEmail);

        Boolean hasHLProduct = false;
        Boolean hasNonHLProduct = false;
        List<Messaging.Email> emailsToSend = new List<Messaging.Email>();

        for(Order o : OppOrder_s) {
            if(o.Division_Code__c == 'HL') {
                hasHLProduct = true;
                System.debug('HL Ordered Product Order Number => '+ o.OrderNumber);
            } else if (o.Division_Code__c != 'HL') {
                hasNonHLProduct = true;
                System.debug('Non HL Ordered Product Order Number => '+o.OrderNumber);
            } 
        } 
               
        if (hasHLProduct && hasNonHLProduct){ 
            // Both HL and Non-HL products
            sendEmail('pranav.chavan181@gmail.com', 'Deal Won Alert_HL', oppMail, OppId, emailsToSend);
            sendEmail('pranav.chavan@kriosispl.in', 'Deal Won Alert_NonHL', oppMail, OppId, emailsToSend);
        } else if (hasHLProduct) {
            // Only HL products
            sendEmail('pranav.chavan181@gmail.com', 'Deal Won Alert_HL', oppMail, OppId, emailsToSend);
        } else if (hasNonHLProduct) {
            // Only Non-HL products
            sendEmail('pranav.chavan@kriosispl.in', 'Deal Won Alert_NonHL', oppMail, OppId, emailsToSend);
        }
        
        // Send all the emails together
        List<Messaging.SendEmailResult> sendResults = Messaging.sendEmail(emailsToSend);

        // Check if there are any email sending failures
        for (Messaging.SendEmailResult result : sendResults) {
            if (!result.isSuccess()) {
                // Handle the error (e.g., log the error, display a message to the user, etc.)
                System.debug('Email sending failed with error: ' + result.getErrors());
            }
        }
    }

    private static void sendEmail(String recipientEmail, String emailTemplateName, String targetObjectId, String whatId, List<Messaging.Email> emailsToSend) {
        System.debug(recipientEmail +emailTemplateName+ targetObjectId+ whatId );
        Messaging.SingleEmailMessage emailMessage = new Messaging.SingleEmailMessage();
        Emailtemplate emailTemplate = [SELECT Id, Subject, Body FROM EmailTemplate WHERE Name = :emailTemplateName];
        emailMessage.setToAddresses(new List<String>{recipientEmail});
        emailMessage.setTemplateId(emailTemplate.Id);
        emailMessage.setTargetObjectId(targetObjectId);
        emailMessage.setWhatId(whatId);
        emailMessage.setHTMLBody(emailTemplate.Body);
        emailMessage.setSaveAsActivity(false);
        
        
        OrgWideEmailAddress[] owea = [SELECT Id FROM OrgWideEmailAddress WHERE Address = 'ajay.joshi@kriosispl.in' LIMIT 1];
        if (owea.size() > 0) {
            emailMessage.setOrgWideEmailAddressId(owea[0].Id);
        }
        
        emailsToSend.add(emailMessage);
    }
    
    @AuraEnabled
    public static void SaveRecord(List<ModifiedRecord> modifiedRecords) {
        Set<Id> oliIds = new Set<Id>();
        Map<Id, OpportunityLineItem> oliMap = new Map<Id, OpportunityLineItem>();

        for (ModifiedRecord record : modifiedRecords) {
            oliIds.add(record.rowId);
        }

        if (!oliIds.isEmpty()) {
            oliMap = new Map<Id, OpportunityLineItem>([SELECT Id, Colour__c, Customization__c, Packing__c, New_Code_Required__c 
                                                       FROM OpportunityLineItem WHERE Id IN :oliIds]);
        }

        for (ModifiedRecord record : modifiedRecords) {
            OpportunityLineItem oli = oliMap.get(record.rowId);
            if (oli != null) {
                if (record.fieldName == 'Colour') {
                    oli.Colour__c = record.modifiedValue;
                } else if (record.fieldName == 'Customization') {
                    oli.Customization__c = record.modifiedValue;
                } else if (record.fieldName == 'Packing') {
                    oli.Packing__c = record.modifiedValue;
                } else if (record.fieldName == 'NewCode') {
                    oli.New_Code_Required__c = record.modifiedValue;
                }
            }
        }

        if (!oliMap.isEmpty()) {
            update oliMap.values();
        }
    }

    public class ModifiedRecord {
        @AuraEnabled
        public String rowId { get; set; }

        @AuraEnabled
        public String fieldName { get; set; }

        @AuraEnabled
        public String modifiedValue { get; set; }
    }    
}

 

Here configured Organisation Wide Address displayed as From: Salesforce Admin NameBut Instead of this I wanted to keep Opportunity Owner Name as From  

I have iterated the OpportunityLineItem in HTML with property ProductData and displayed the OPP LineItem in tabular format.
I have to edit the OppLineItem and wanted to save in apex below is my Apex , HTML, and JS code for the same. Please correct the code.

HTML:

<template if:true={EditButton}>
    <template for:each={ProductData} for:item="row">
        <tr key={row.Id}>
            <td style="text-align: center; padding: 6px; border: 1px solid;">{row.Product2.Description}</td>
            <td style="text-align: center; padding: 6px; border: 1px solid;">{row.Quantity}</td>
            <td style="text-align: center; padding: 6px; border: 1px solid;">{row.UnitPrice}</td>
            <td style="text-align: center; padding: 6px; border: 1px solid;">{row.TotalPrice}</td>
            <td class="slds-p-around_xx-small" style="align: center; padding: 6px; border: 1px solid;"> 
                <lightning-input type='text' name='Colour' data-id={row.Id} value={Colour} disabled={disabled} data-field-modified>
                </lightning-input></td>
            <td class="slds-p-around_xx-small" style="align: center; padding: 6px; border: 1px solid;"> 
                <lightning-input type='text' name='Customization' data-id={row.Id} value={Customization} disabled={disabled} data-field-modified></lightning-input></td>
            <td class="slds-p-around_xx-small" style="text-align: center; padding: 6px; border: 1px solid;">
                <lightning-input type='text' name='Packing' data-id={row.Id} value={Packing} disabled={disabled} data-field-modified></lightning-input></td>
            <td class="slds-p-around_xx-small" style="text-align: center; padding: 6px; border: 1px solid;"> 
                                <lightning-combobox label="" name="NewCode" variant="label-stacked" placeholder="Select Option" class="priorityAlign" value={New_Code_Required} data-id={row.Id} options={NewCodeOptions} disabled={disabled} data-field-modified></lightning-combobox></td>
        </tr>
    </template>
</template>

JS:

handleSave(){
        this.sendmail = false;

        const modifiedRecords = [];
        const inputFields = this.template.querySelectorAll('[data-field-modified]');

        inputFields.forEach((input) => {
            const rowId = input.dataset.id;
            const fieldName = input.name;
            const modifiedValue = input.value;
            modifiedRecords.push({ rowId, fieldName, modifiedValue });
        });

        console.log("Modified Records: ", modifiedRecords);
        
        SaveRecord({ modifiedRecords })
        .then(result => {
            console.log('Data Saved Successfully...');
            this.data = result;
            console.log('DATA ::', this.data);

            const evt = new ShowToastEvent({
                title: 'Save Data',
                message: 'Save sucessfully',
                variant: 'success',
                mode: 'dismissable'
            });

            this.dispatchEvent(evt);
            console.log("Event Dispatched and OLI Saved Successfully...!");

        })
        .catch(error => {
            console.log('Inside Save Action error');
            this.error = error;
            console.log('Error ::', this.error);
        })
    }

Apex:

@AuraEnabled
    public static void SaveRecord(List<ModifiedRecord> modifiedRecords) {
        System.debug('modified records=====>'+modifiedRecords);
        
          List<OpportunityLineItem> oppLineItemsToUpdate = new List<OpportunityLineItem>();

          for (ModifiedRecord record : modifiedRecords) {
            OpportunityLineItem oli = [SELECT Id,Product2.Description, Quantity, UnitPrice, TotalPrice, Colour__c, Customization__c, Packing__c, New_Code_Required__c FROM OpportunityLineItem WHERE Id =: record.rowId];
            
            if (oli != null) {
                  if (record.fieldName == 'Colour') {
                    oli.Colour__c = record.modifiedValue;
                    System.debug('Colour:'+oli.Colour__c);
                  } else if (record.fieldName == 'Customization') {
                    oli.Customization__c = record.modifiedValue;
                    System.debug('Customization:'+oli.Customization__c);
                  } else if (record.fieldName == 'Packing') {
                    oli.Packing__c = record.modifiedValue;
                    System.debug('Packing:'+oli.Packing__c);
                  } else if (record.fieldName == 'NewCode') {
                    oli.New_Code_Required__c = record.modifiedValue;
                    System.debug('New_Code_Required:'+oli.New_Code_Required__c);
              }
                oppLineItemsToUpdate.add(oli);
                System.debug('oppLineItemsToUpdate'+oppLineItemsToUpdate);
            }
        }
        if (!oppLineItemsToUpdate.isEmpty()) {
        update oppLineItemsToUpdate;
    }
        System.debug('oppLineItemsToUpdate'+oppLineItemsToUpdate);
        
    }
    
    public class ModifiedRecord {
          @AuraEnabled
          public String rowId { get; set;}
        
          @AuraEnabled
          public String fieldName { get; set;}  
        
          @AuraEnabled
          public String modifiedValue { get; set;}    
        
    }

Provide the solution asap.....
I have a scenario. When user mark the Opportunity Stage as "Indent" i.e. "Closed Won" then LWC modal popup should be opened. 

I have developed the LWC modal popup. When User mark the Stage "Indent" as close then trigger will fire and platform event will be published. from that Platform event I sent the Current Opportunity Record ID, Current Logged In User ID, and Message.

I have subscribed the platform event in JS file and on the condition of Current UserID & Current Opportunity Record ID I am displaying the Modal popup.

if (objData.OpportunityId__c === self.recordId && obj.data.payload.
UserId__c === self.Current_UserId) 
{
console.log("Inside If Condition");
//this.message = objData.message__c;
self.OpenModal();
}

But issue which i am facing that when i indent the opportunity then modal popup will be opened to another users thos who are working on opportunities. 

Expected Result: when user indent the Opportunity then immediately modal should be opened only for that opportunity and for the same logged in user. 

Below is my Trigger and JS files.

Trigger:
trigger OpportunityStageTrigger on Opportunity (before update) {
    
    Map<Id, String> oldStageMap = new Map<Id, String>();
    List<OpportunityActivityEvent__e> eventList = new List<OpportunityActivityEvent__e>();
    
    for (Opportunity opp : Trigger.old) {
        oldStageMap.put(opp.Id, opp.StageName);
    }
    
    for (Opportunity opp : Trigger.new) {
        if (oldStageMap.containsKey(opp.Id)) {
            
            String oldStage = oldStageMap.get(opp.Id);
            String newStage = opp.StageName;
            
            if (oldStage != newStage) {
                if (oldStage != 'Indent' && newStage == 'Indent') {
                    
                    // opp.IsStageChanged__c = false;
                    opp.IsStageChanged__c = true;
                    
                    OpportunityActivityEvent__e event = new OpportunityActivityEvent__e();
                    event.message__c = 'Opportunity ' + opp.Name + ' has been closed as won.';
                    event.OpportunityId__c = opp.Id;
                    event.UserId__c = UserInfo.getUserId();
                    
                    System.debug('Event Message =>'+event.message__c);
                    System.debug('Current Opportunity RecordId:'+ event.OpportunityId__c);
                    System.debug('Current Logged In UserId:'+ event.UserId__c);
                    
                    eventList.add(event);
                    System.debug('Value Added to list');
                    
                    if (!eventList.isEmpty()) {
                        EventBus.publish(eventList);
                        System.debug(eventList);
                       }
                } 
            }
        }
    }
}
=====================================================
JS file:

import { LightningElement, api, wire, track} from 'lwc';
import getOppDetails from '@salesforce/apex/DealWonVerification.getOppDetails'; 
import getOpportunityLineItems from '@salesforce/apex/DealWonVerification.getOpportunityLineItems'; 
import getOrdersdetails from '@salesforce/apex/DealWonVerification.getOrdersdetails';
import toSendEmailWithTemplate from '@salesforce/apex/DealWonVerification.toSendEmailWithTemplate';
import getSaveData from '@salesforce/apex/DealWonVerification.getSaveData';
import { subscribe, unsubscribe, onError, setDebugFlag, isEmpEnabled } from 'lightning/empApi';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import { refreshApex } from '@salesforce/apex';
import User_ID from '@salesforce/user/Id';
export default class Vip_DealWonVerification extends LightningElement {
    @api recordId;
    Current_UserId = User_ID;
    @track message;
    subscription = {};
    @api channelName = '/event/OpportunityActivityEvent__e';
    ShowModal = false;
    EditButton = false;
    booleanv = true;
    booleanvar = true;
    sendboolean = false;
    // Opportunity Properties
    @track OpportunityData;
    Opp_Id;
    Opp_Name;
    Acc_Name;
    Close_Date;
    Amt;
    Opp_Stage;
    @track RSCM;
    @track RSales;
    // Product Properties
    @track ProductData;
    @track Colour;
    @track Customization;
    @track Packing;
    @track New_Code_Required;
    @track OrderData;
    // handlechangeproperties
    RemarksSales;
    RemarksSCM;
    Prod_Colour;
    Prod_Customization;
    Prod_Packing;
    Prod_NewCode;

    OpenModal(){
        
        this.ShowModal = true;
    }
    
    CloseModal(){
        this.ShowModal = false;
        this.booleanv = true;
    }
    
    connectedCallback() {
        // Display Server Error     
        this.registerErrorListener();
        this.handleSubscribe();
    }
    registerErrorListener() {
        onError(error => {
            console.log('Received error from server: ', JSON.stringify(error));
        });
    }
    handleSubscribe() {
        console.log("Inside the handleSubscriber Function");
        const self = this;
        console.log("before messageCallback");
        const messageCallback = function (response) {
            console.log("Inside the messageCallback");
            console.log('Message Received in JSON Format ===>: ', JSON.stringify(response));
            console.log('Message Received===> ', response);
            var obj = JSON.parse(JSON.stringify(response));
            const Opp_Id = obj.data.payload.OpportunityId__c;
            const Curr_UserId = obj.data.payload.UserId__c;
            console.log(obj.data.payload);
            console.log(obj.data.payload.message__c);
            console.log(Opp_Id, "and", self.recordId);
            console.log(Curr_UserId , "and", self.Current_UserId);
            console.log(self.channelName);
            let objData = obj.data.payload;
            console.log("Before If Condition");
           if (objData.OpportunityId__c === self.recordId && obj.data.payload.UserId__c === self.Current_UserId) {
               console.log("Inside If Condition");
                //this.message = objData.message__c;
               self.OpenModal();
           }
        };
        subscribe(this.channelName, -1, messageCallback).then(response => {
            // Response contains the subscription information on subscribe call
            console.log('Subscription request sent to: ', JSON.stringify(response.channel));
            this.subscription = response;
        });
    }
    ShowToast(title, message, variant, mode) {
        const evt = new ShowToastEvent({
            title: title,
            message: message,
            variant: variant,
            mode: mode
        });
        this.dispatchEvent(evt);
    }
    @wire (getOppDetails,{OppId:'$recordId'}) 
    wiredOppData({error, data}){
        if(data){
            this.OpportunityData = data;
            console.log("Wired Opportunity Data:", this.OpportunityData);
            this.error = undefined;
            // Opportunity Fields
            this.Opp_Id = this.OpportunityData[0].Id;
            console.log('Opportunity Id =>', this.OpportunityData[0].Id);
            this.Opp_Name = this.OpportunityData[0].Name;
            console.log('Opportunity Name =>',this.OpportunityData[0].Name); 
            this.Acc_Name = this.OpportunityData[0].Account.Name;
            console.log('Account Name =>',this.OpportunityData[0].Account.Name);
            this.Close_Date = this.OpportunityData[0].CloseDate;
            console.log('Close Date =>',this.OpportunityData[0].CloseDate);
            this.Amt = this.OpportunityData[0].Amount;
            console.log('Amount =>',this.OpportunityData[0].Amount);
            this.Opp_Stage = this.OpportunityData[0].StageName;
            console.log('Opportunity Stage =>', this.Opp_Stage);
            this.RSCM = this.OpportunityData[0].Remark_by_SCM__c;
            console.log('Remarks By SCM =>', this.OpportunityData[0].Remark_by_SCM__c);
            this.RSales = this.OpportunityData[0].Remarks_by_the_Sales__c;
            console.log('Remarks By Sales =>',this.OpportunityData[0].Remarks_by_the_Sales__c);
        } else if(error){
            this.error = error;
            this.OpportunityData = undefined;
        }
    }
    @wire (getOpportunityLineItems, {OppId: '$recordId'})
    wiredProdData ({error, data}){
        if(data){
            this.ProductData = data;
            console.log("Wired Opportunity Line Item Data:", this.ProductData);
            this.error = undefined;
            this.Colour = this.ProductData[0].Colour__c;
            console.log('Colour:',this.ProductData[0].Colour__c);
            this.Customization = this.ProductData[0].Customization__c;
            console.log('Customization:', this.ProductData[0].Customization__c);
            this.Packing = this.ProductData[0].Packing__c;
            console.log('Packing:', this.ProductData[0].Packing__c);
            this.New_Code_Required = this.ProductData[0].New_Code_Required__c;
            console.log('New Code Required:',this.ProductData[0].New_Code_Required__c);
        }else if(error){
            this.error = error;
            this.ProductData = undefined;
        }
    }
    @wire (getOrdersdetails,{OppId: '$recordId'})
    wiredOrdData({error, data}){
        if(data){
            this.OrderData = data;
            console.log("Wired Order data:", this.OrderData);
            this.errorv = undefined;
        }else if(error){
            this.error = error;
            this.OrderData = undefined;
        }
    }
    handleEdit(event){
        this.EditButton = true;
        this.booleanvar = false;
        this.sendboolean = true;
        console.log("Inside the Edit Action");
        this.Opt.Remark_by_SCM__c = event.target.value;
        this.Opt.Remarks_by_the_Sales__c = event.target.value;
        this.OppLineIt.Colour__c = event.target.value;
        this.OppLineIt.Customization__c = event.target.value;
        this.OppLineIt.Packing__c = event.target.value;
        this.OppLineIt.New_Code_Required__c = event.target.value;
    }
    handleChange(event){
        if(event.target.name === 'RemarksBySales'){
            this.RemarksSales = event.target.value;
            console.log('Updated Remarks By Sales', this.RemarksSales);
        }
        if(event.target.name === 'RemarksBySCM'){
            this.RemarksSCM = event.target.value;
            console.log('Updated Remarks By SCM', this.RemarksSCM);
        }
        if(event.target.name === 'Colour'){
            this.Prod_Colour = event.target.value;
            console.log('Updated Colour:', this.Prod_Colour);
        }
        if(event.target.name === 'Customization'){
            this.Prod_Customization = event.target.value;
            console.log('Updated Customization value:', this.Prod_Customization);
        }
        if(event.target.name === 'Packing'){
            this.Prod_Packing = event.target.value;
            console.log('Updated Packing Value: ', this.Prod_Packing);
        }
        if(event.target.name === 'NewCode'){
            this.Prod_NewCode = event.target.value;
            console.log('Updated New Code: ', this.Prod_NewCode);
        }
    }
    // handle save operation should be async
    async handleSave(){
        console.log('Inside the Save Action');
        this.booleanvar = true;
        this.sendboolean = false;
        getSaveData ({OppId: this.recordId, remarksbyscm: this.RemarksSCM, remarksbysales: this.RemarksSales, colr: this.Prod_Colour, customization: this.Prod_Customization, packing: this.Prod_Packing, newcoderequired: this.Prod_NewCode})
        .then(result =>{
            console.log('Inside data');
            this.data = result;
            console.log('DATA ::',this.data);
     
                const evt = new ShowToastEvent({
                    title: 'Save Data',
                    message: 'Save sucessfully',
                    variant: 'success',
                    mode: 'dismissable'
                });
                this.dispatchEvent(evt);
                console.log("Event Dispatched...!");
                // location.reload();
                refreshApex(this.wiredOppData);
        })
        .catch(error => {
            console.log('Inside error');
            this.error = error;
            console.log('Error ::',this.error);
        })
    }
    handleSendEmail(){
        
        console.log('Inside the Send Email Method');
        toSendEmailWithTemplate({OppId: this.recordId})
        .then((data) => {
            console.log('Email sent successfully:', data);
            
            const evt = new ShowToastEvent({
                title: 'Send Indent Email',
                message: 'Email Send Successfully',
                variant: 'success',
                mode: 'dismissable'
            });
            this.dispatchEvent(evt);
          })
          .catch((error) => {
            console.error('Error sending email:', error);
          });
    }
}

 
I have a scenario. 
If current month is May 2023. Create a report for all opportunities  of May 2022.  How we can create this report.
I have created the VF email template. It willl be sent to email Id when we click on button which is available on Opportunity. We user receive the email then there should be the sender as particular email Id instead of "noreply@salesforce.com". 

So how to mention the sender in vf Email Template?
I have i below code which shows product catalogue in three  Columns for desktop. When user opensCatalogue displayed in two columns. It should be displayed in one column the catalogue in salesforce 1 mobile application it should be displayed in one column instead of two columns. What I have to do changes in below code.

HTML:

<template>
    <template if:true={productsFound}>
        <lightning-layout multiple-rows style="height: 200px; width: auto " >
            <template for:each={Products} for:item="product">
                <lightning-layout-item key={product.id} size="6" padding="around-small">
                    <lightning-layout  multiple-rows>
                        <div class="slds-box carousel"  style="width: 100%;background-color:white;">
                            <lightning-layout style="height: 150px;">
    
                                <lightning-layout-item size="5 " padding="around-small">
                                    <div class="productImage slds-align_absolute-center">
                                        <lightning-formatted-rich-text style="height: 130px;" value={product.Product_Images__c} onclick={ShowModal}>
                                        </lightning-formatted-rich-text>
                                    </div>
                                </lightning-layout-item>
                                
                                <lightning-layout-item size="7" padding="around-small" >
                                    <lightning-card  title= ""  style="height: 60px;">
    
                                        <lightning-layout-item padding="around-small" size="12" small-device-size="6" large-device-size="6" medium-device-size="6">
                                            <div class="ProductName">{product.Product_Description__c}</div>
                                        </lightning-layout-item>
                                        <br>

                                        <lightning-layout-item  padding="around-small" size="12" small-device-size="6" large-device-size="6" medium-device-size="6">
                                            Brand : {product.Brand_Description__c}
                                        </lightning-layout-item>
                                        <br>
    
                                        <lightning-layout-item  padding="around-small" size="12" small-device-size="6" large-device-size="6" medium-device-size="6">
                                            Product Name : {product.Product_Description__c} 
                                        </lightning-layout-item>
                                        <br>
    
                                        <lightning-layout-item  padding="around-small" size="12" small-device-size="6" large-device-size="6" medium-device-size="6">
                                            MRP : {product.MRP__c}
                                        </lightning-layout-item>
                                        <br>                  
                                    </lightning-card>                                                     
                                </lightning-layout-item>
                            </lightning-layout>
                        </div>
                    </lightning-layout>                    
                </lightning-layout-item>
            </template>
        </lightning-layout>
    </template>

    <template if:true={isShowModal}>
        <div class="slds-modal slds-fade-in-open slds-backdrop">
            <section role="dialog" tabindex="-1" aria-labelledby="modal-heading-01" aria-modal="true" aria-describedby="modal-content-id-1" class="slds-modal slds-fade-in-open">
                <div class="slds-modal__container">
                    <lightning-modal-header>
                        <!-- sldsValidatorIgnoreNextLine -->
                        <!-- sldsValidatorIgnoreNextLine -->
                        <!-- sldsValidatorIgnoreNextLine -->
                        <lightning-button-icon icon-name="utility:close" alternative-text="Close this window" size="large" 
                         variant="bare-inverse" onclick={closemodal} class="slds-modal__close">
                        </lightning-button-icon>
                    </lightning-modal-header>
                    <!--sldsValidatorIgnoreNextLine -->
                    <div class="slds-modal__content" id="modal-content-id-2">
                        <lightning-formatted-rich-text class="slds-align_absolute-center" value= {selectedImage}>
                        </lightning-formatted-rich-text>
                    </div>
                    <lightning-modal-footer>
                        <lightning-button class="slds-button" variant="Brand" label="Cancel" onclick={closemodal}> Close</lightning-button>
                    </lightning-modal-footer>
                </div>
            </section>
        </div>
    </template>
    
    <template if:true={ProductNotFound}>
        <div>
            <lightning-card title="">
                <p class="slds-text-align_center">
                    <b class="slds-text-heading_medium" style="color:#de4923;">Products Not Found...</b><br>
                    <b class="slds-text-heading_small">Uh Oh, We can't seem to find the product you are looking for.<br>
                                                        Try to search another interesting Products.</b>
                </p>
            </lightning-card>
        </div> 
    </template> 
</template>
I have a scenario.

I have products properties in which all product details stored which are retrived from apex class.

In the object I have Product_Image__c named rich text field is there in which my all individual product images are stored.

In my LWC Component when i clicked on "View Image" button same related image should be open on popup. 

HTML:

<lightning-button variant="success" label="View Product Image" class="slds-var-m-left_x-small" 
 title="View Product Details" value={product.Id} onclick={showmodal}></lightning-button>
    <template if:true={isShowModal}>
        <div class="slds-modal__container">
                    <header class="slds-modal__header">
                        <!-- sldsValidatorIgnoreNextLine -->
                            <lightning-button-icon icon-name="utility:close" alternative-text="Close this window" size="large" 
                    variant="bare-inverse" onclick={CloseModal} class="slds-modal__close">
                            </lightning-button-icon>
                        </header>
            <div class="slds-modal__content slds-var-p-around_medium" id="modal-content-id">
                <lightning-formatted-rich-text value={selectedproductimage.product.Product_Images__c} onclick={openModal}>
                                </lightning-formatted-rich-text>
                        </div>
        </div>
    </template>

JS:

export default class VIP_ProductCatalogue extends NavigationMixin (LightningElement) {

    @track Products;
    @track productsFound;
    @track isModalOpen = false;
    @track isShowModal = false;
    selectedproductimage;

showmodal() 
    {
        this.selectedproductimage = this.currentTarget.template.item;
        this.isShowModal = true;
    }
CloseModal() 
    {
        this.isShowModal = false;
    }

Below image is for ref of my UI

User-added image
I have a scenario, 

I have to show opportunity details, Its product details, and order details and order schedule details in lightning email template....
I have written the lwc code for the modal popup to display the pending opportunities of the currently logged-in user.

Currently, my popup is displayed on the home page once the home page appears on screen. i.e. onloading.

But I want to display the popup on home page once user login to salesforce and came to the home page. if a user opens any other tab and came back to the home page it must not be displayed on home page. it should be displayed on home page when the user login to salesforce.

Note: I don't want to create login flows.


HTML file:

<template>
    <template if:true={isModalOpen}>
        <div class="slds-modal slds-fade-in-open slds-backdrop">
        <section role="dialog" tabindex="-1" aria-labelledby="modal-heading-01" aria-modal="true" aria-describedby="modal-content-id-1" class="slds-modal slds-fade-in-open">
            <div class="slds-modal__container">
                <header class="slds-modal__header">
                    <lightning-button-icon icon-name="utility:close" alternative-text="Close this window" size="large" variant="bare-inverse" onclick={closeModal} class="slds-modal__close">
                    </lightning-button-icon>
                    <h2 id="modal-heading" class="slds-text-heading_medium slds-hyphenate">Pending Opportunity Alerts</h2>
                </header>
               
                <div class="slds-modal__content" id="modal-content-id">
                    <p><b> &nbsp; Hello!...
                    </b></p>
                    <p><b> &nbsp; You have some pendings opportunities...Please work on it before month end.
                    </b></p>
                    <p><b> &nbsp; For more detials see the reports.
                    </b></p>
                </div>
               
                <footer class="slds-modal__footer">
                    <button class="slds-button slds-button_neutral" onclick={navigateToReport} title="View Report">View Report</button>
                    <button class="slds-button slds-button_brand" onclick={submitDetails} title="Close">Close</button>
                </footer>
            </div>
        </section>
    </div>
    </template>
 </template>
==============================================
JS File:

import { LightningElement, track ,wire} from 'lwc';
import { NavigationMixin } from 'lightning/navigation';
import Id from '@salesforce/user/Id';
import getCount from '@salesforce/apex/PendingOppCount.getCount';
export default class POPUP extends NavigationMixin (LightningElement) {
    @track isModalOpen = false;
    @track userId = Id;
    constructor(){
        super();
        this.getCount();
        console.log('Currently Logged in Useer ID:-',this.userId);
    }
    openModal() {
       
        this.isModalOpen = true;
    }
    closeModal() {
       
        this.isModalOpen = false;
    }
    submitDetails() {
       
        this.isModalOpen = false;
    }
    getCount(){
        console.log('Inside getCount');
        getCount({CurrUserId: this.userId})
        .then(result => {
            //console.log('Inside getCount');
            this.data = result;
            console.log('Inside getCount',this.data);
            this.error = undefined;
            if(this.data > 0){
                console.log('Inside openModal');
                this.openModal();
            }else{
                console.log('Inside closeModal');
                this.closeModal();
            }
           
        })
        .catch(error => {
            console.log('Inside error',this.error);
            this.error = error;
            this.data = undefined;
        });
}
    navigateToReport() {
        const config = {
            type: 'standard__webPage',
            attributes: {
                url: '/lightning/r/Report/00O5g00000GmtuKEAR/view?queryScope=userFolders'
            }
        };
        this[NavigationMixin.Navigate](config);
    }
}
==============================================

xml file:

<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>55.0</apiVersion>
    <isExposed>true</isExposed>
    <targets>
        <target>lightning__AppPage</target>
        <target>lightning__RecordPage</target>
        <target>lightning__HomePage</target>
        <target>lightning__FlowScreen</target>
    </targets>
</LightningComponentBundle>
When current user have 10 opportunities, 4 are pending and remaining are closed won or closed lost and
When user (Sales Executive Profiles user) login to salsforce on month end (30th, 31th) including leap year (28th, 29th) then he/she will not able to create the new opportunities until he/she not completed the opportunities i.e. stage = Closed Won/Closed Lost.

Inshort: When opportunities are pending Current user (Sales Executive Profiles User)not able to create the new opportunities on month end. (Using Validation Rule)

I have to create the validation rule for this. I need Help.
I have to send an email alert to the opportunity owner on the last fifth day of the current user....
I have i below code which shows product catalogue in three  Columns for desktop. When user opensCatalogue displayed in two columns. It should be displayed in one column the catalogue in salesforce 1 mobile application it should be displayed in one column instead of two columns. What I have to do changes in below code.

HTML:

<template>
    <template if:true={productsFound}>
        <lightning-layout multiple-rows style="height: 200px; width: auto " >
            <template for:each={Products} for:item="product">
                <lightning-layout-item key={product.id} size="6" padding="around-small">
                    <lightning-layout  multiple-rows>
                        <div class="slds-box carousel"  style="width: 100%;background-color:white;">
                            <lightning-layout style="height: 150px;">
    
                                <lightning-layout-item size="5 " padding="around-small">
                                    <div class="productImage slds-align_absolute-center">
                                        <lightning-formatted-rich-text style="height: 130px;" value={product.Product_Images__c} onclick={ShowModal}>
                                        </lightning-formatted-rich-text>
                                    </div>
                                </lightning-layout-item>
                                
                                <lightning-layout-item size="7" padding="around-small" >
                                    <lightning-card  title= ""  style="height: 60px;">
    
                                        <lightning-layout-item padding="around-small" size="12" small-device-size="6" large-device-size="6" medium-device-size="6">
                                            <div class="ProductName">{product.Product_Description__c}</div>
                                        </lightning-layout-item>
                                        <br>

                                        <lightning-layout-item  padding="around-small" size="12" small-device-size="6" large-device-size="6" medium-device-size="6">
                                            Brand : {product.Brand_Description__c}
                                        </lightning-layout-item>
                                        <br>
    
                                        <lightning-layout-item  padding="around-small" size="12" small-device-size="6" large-device-size="6" medium-device-size="6">
                                            Product Name : {product.Product_Description__c} 
                                        </lightning-layout-item>
                                        <br>
    
                                        <lightning-layout-item  padding="around-small" size="12" small-device-size="6" large-device-size="6" medium-device-size="6">
                                            MRP : {product.MRP__c}
                                        </lightning-layout-item>
                                        <br>                  
                                    </lightning-card>                                                     
                                </lightning-layout-item>
                            </lightning-layout>
                        </div>
                    </lightning-layout>                    
                </lightning-layout-item>
            </template>
        </lightning-layout>
    </template>

    <template if:true={isShowModal}>
        <div class="slds-modal slds-fade-in-open slds-backdrop">
            <section role="dialog" tabindex="-1" aria-labelledby="modal-heading-01" aria-modal="true" aria-describedby="modal-content-id-1" class="slds-modal slds-fade-in-open">
                <div class="slds-modal__container">
                    <lightning-modal-header>
                        <!-- sldsValidatorIgnoreNextLine -->
                        <!-- sldsValidatorIgnoreNextLine -->
                        <!-- sldsValidatorIgnoreNextLine -->
                        <lightning-button-icon icon-name="utility:close" alternative-text="Close this window" size="large" 
                         variant="bare-inverse" onclick={closemodal} class="slds-modal__close">
                        </lightning-button-icon>
                    </lightning-modal-header>
                    <!--sldsValidatorIgnoreNextLine -->
                    <div class="slds-modal__content" id="modal-content-id-2">
                        <lightning-formatted-rich-text class="slds-align_absolute-center" value= {selectedImage}>
                        </lightning-formatted-rich-text>
                    </div>
                    <lightning-modal-footer>
                        <lightning-button class="slds-button" variant="Brand" label="Cancel" onclick={closemodal}> Close</lightning-button>
                    </lightning-modal-footer>
                </div>
            </section>
        </div>
    </template>
    
    <template if:true={ProductNotFound}>
        <div>
            <lightning-card title="">
                <p class="slds-text-align_center">
                    <b class="slds-text-heading_medium" style="color:#de4923;">Products Not Found...</b><br>
                    <b class="slds-text-heading_small">Uh Oh, We can't seem to find the product you are looking for.<br>
                                                        Try to search another interesting Products.</b>
                </p>
            </lightning-card>
        </div> 
    </template> 
</template>
Hi,

I have added the number of product to Opportunity. how to call the product information email template?

Is this need to add the product to price book entry before add the template? Kindly give any example

Thanks