• Prasanth R
  • NEWBIE
  • 35 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 23
    Questions
  • 23
    Replies
i created a record by usig LWC and uploaded the file.But In UI it's not displaying the file for the corresponding record.Kidl someone help me

below i added the code:

<template>
   
    <lightning-button class="button" variant="brand" label="Gas station" 
    title="Gas Station"  onclick={showModalBox}>
</lightning-button>


<!-- modal start -->      
<template if:true={isShowModal}>

<!--
I Used SLDS for this code
Here is link https://www.lightningdesignsystem.com/components/modals/
--> 

<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">
<!-- modal header start -->
<header class="slds-modal__header">
<button class="slds-button slds-button_icon slds-modal__close slds-button_icon-inverse" title="Close" onclick={hideModalBox}>
<lightning-icon icon-name="utility:close" alternative-text="close" variant="inverse"
size="small" ></lightning-icon>
<span class="slds-assistive-text">Close</span>
</button>
<h2 id="modal-heading-01" class="slds-text-heading_medium slds-hyphenate" style="background-color: rgb(218, 8, 116);">New Gas station</h2>
</header>

<!-- modal body start -->
<div class="slds-modal__content slds-p-around_large" id="modal-content-id-1">
        <lightning-card>
            <div class="slds-grid slds-gutters">
            <div class="slds-col slds-size_1-of-2" style="width: 300px;">
                <span>
                <lightning-input label="Firm Name" name="Firm_Name__c" type="text" value={formFields.Firm_Name__c} onchange={changeHandler}></lightning-input>
                <lightning-input label="owner Name" name="Owner_Name__c" type="text" value={formFields.Owner_Name__c} onchange={changeHandler}></lightning-input>
                <lightning-input label="Phone Number" name="Phone_No__c" type="text" value={formFields.Phone_No__c} onchange={changeHandler}></lightning-input>               
                
                <lightning-card title="Partnership details" >
                    <lightning-file-upload
                        label="Attach receipt"
                        name="fileUploader"
                        accept={acceptedFormats}
                        record-id={recordId}
                        onuploadfinished={handleUploadFinished}
                        multiple>
                </lightning-file-upload>
                </lightning-card>

                <lightning-card title="Gst details" >
                    <lightning-file-upload
                        label="Attach receipt"
                        name="fileUploader"
                        accept={acceptedFormats}
                        record-id={recordId}
                        onuploadfinished={handleUploadFinished}
                        multiple>
                </lightning-file-upload>
                </lightning-card>
            </span>
            </div>

            <div class="slds-col slds-size_2-of-2" style="width: 300px;">
                    <lightning-input label="Email Id" name="Email_Id__c" type="text" value={formFields.Email_Id__c} onchange={changeHandler}></lightning-input>
                    <lightning-input label="Pan No" name="Pan_Number__c" type="text" value={formFields.Pan_Number__c} onchange={changeHandler}></lightning-input>
                    <lightning-input label="Gst No" name="Gst_Number__c" type="text" value={formFields.Gst_Number__c} onchange={changeHandler}></lightning-input>
                <lightning-card title="Pan card details" >
                    <lightning-file-upload
                        label="Attach receipt"
                        name="fileUploader"
                        accept={acceptedFormats}
                        record-id={recordId}
                        onuploadfinished={handleUploadFinished}
                        multiple>
                </lightning-file-upload>
                </lightning-card>
                </div>
                
            </div>
            </lightning-card>
            <lightning-button label="Submit" variant="brand" onclick={handleSave} ></lightning-button>
            &nbsp; &nbsp;
            <lightning-button label="Cancel" variant="brand" onclick={handleCancel} ></lightning-button>
</div>

<!-- modal footer start-->
<!-- <footer class="slds-modal__footer"> -->
<!-- <button class="slds-button slds-button_neutral" onclick={hideModalBox}>Cancel</button> -->
<!-- <button class="slds-button slds-button_neutral" onclick={hideModalBox}>Submit</button> -->
<!-- </footer> -->

</div>
</section>
<div class="slds-backdrop slds-backdrop_open"></div>
</template>
<!-- modal end -->
</template>

js:
js:
import { LightningElement,track,api } from 'lwc';
import {ShowToastEvent} from 'lightning/platformShowToastEvent';
import { createRecord } from 'lightning/uiRecordApi';
import INNAD_GASSTATION_OBJECT from '@salesforce/schema/INNAD_Gas_Station__c';

import OWNER_NAME_FIELD from '@salesforce/schema/INNAD_Gas_Station__c.Owner_Name__c';
import PHONE_NO_FIELD from '@salesforce/schema/INNAD_Gas_Station__c.Phone_No__c';
import EMAIL_ID_FIELD from '@salesforce/schema/INNAD_Gas_Station__c.Email_Id__c';
import PAN_NO_FIELD from '@salesforce/schema/INNAD_Gas_Station__c.Pan_Number__c';

export default class GasStation extends LightningElement {

    formFields = {
        Firm_Name__c:'',
        Owner_Name__c:'',
        Phone_No__c:'',
        Email_Id__c:'',
        Pan_Number__c:'',
        Gst_Number__c:''
    }
    changeHandler(event){
        const {value, name} = event.target
        this.formFields = { ...this.formFields, [name]:value}
    }

    handleSave(){
        const fields ={}
        fields[OWNER_NAME_FIELD.fieldApiName] = this.formFields.Owner_Name__c
        console.log(this.formFields.Owner_Name__c)
        fields[PHONE_NO_FIELD.fieldApiName] = this.formFields.Phone_No__c
        console.log(this.formFields.Owner_Name__c)
        fields[EMAIL_ID_FIELD.fieldApiName] = this.formFields.Email_Id__c
        console.log(this.formFields.Owner_Name__c)
        fields[PAN_NO_FIELD.fieldApiName] = this.formFields.Pan_Number__c
        console.log(this.formFields.Owner_Name__c)
        let recordInput = { apiName: INNAD_GASSTATION_OBJECT.objectApiName, fields}
        createRecord(recordInput).then(result=>{
            this.formFields={}
            console.log('Record created ID', JSON.stringify(result.id))
        }).catch(error=>{
            console.error(error)
        })
    }

    @track isShowModal = false;

    showModalBox() {  
        this.isShowModal = true;
    }
    
    hideModalBox() {  
        this.isShowModal = false;
    }
    
    handleCancel() {  
        this.isShowModal = false;
    }

    @api recordId;
    get acceptedFormats() {
        return ['.pdf', '.png','.jpg','.jpeg'];
    }
    handleUploadFinished(event) {
        // Get the list of uploaded files
        const uploadedFiles = event.detail.files;
        let uploadedFileNames = '';
        for(let i = 0; i < uploadedFiles.length; i++) {
            uploadedFileNames += uploadedFiles[i].name + ', ';
        }
        this.dispatchEvent(
            new ShowToastEvent({
                title: 'Success',
                message: uploadedFiles.length + ' Files uploaded Successfully: ' + uploadedFileNames,
                variant: 'success',
            }),
        );
    }    
}

<?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__HomePage</target>
        <target>lightning__RecordPage</target>
        <target>lightning__Tab</target>
    </targets>
</LightningComponentBundle>

User-added image
User-added image
i created a record by usig LWC and uploaded the file.But In UI it's not displaying the file for the corresponding record..kindly someonUser-added imageUser-added imagee help me.

below i added the code:

<template>
   
    <lightning-button class="button" variant="brand" label="Gas station" 
    title="Gas Station"  onclick={showModalBox}>
</lightning-button>


<!-- modal start -->      
<template if:true={isShowModal}>

<!--
I Used SLDS for this code
Here is link https://www.lightningdesignsystem.com/components/modals/
--> 

<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">
<!-- modal header start -->
<header class="slds-modal__header">
<button class="slds-button slds-button_icon slds-modal__close slds-button_icon-inverse" title="Close" onclick={hideModalBox}>
<lightning-icon icon-name="utility:close" alternative-text="close" variant="inverse"
size="small" ></lightning-icon>
<span class="slds-assistive-text">Close</span>
</button>
<h2 id="modal-heading-01" class="slds-text-heading_medium slds-hyphenate" style="background-color: rgb(218, 8, 116);">New Gas station</h2>
</header>

<!-- modal body start -->
<div class="slds-modal__content slds-p-around_large" id="modal-content-id-1">
        <lightning-card>
            <div class="slds-grid slds-gutters">
            <div class="slds-col slds-size_1-of-2" style="width: 300px;">
                <span>
                <lightning-input label="Firm Name" name="Firm_Name__c" type="text" value={formFields.Firm_Name__c} onchange={changeHandler}></lightning-input>
                <lightning-input label="owner Name" name="Owner_Name__c" type="text" value={formFields.Owner_Name__c} onchange={changeHandler}></lightning-input>
                <lightning-input label="Phone Number" name="Phone_No__c" type="text" value={formFields.Phone_No__c} onchange={changeHandler}></lightning-input>               
                
                <lightning-card title="Partnership details" >
                    <lightning-file-upload
                        label="Attach receipt"
                        name="fileUploader"
                        accept={acceptedFormats}
                        record-id={recordId}
                        onuploadfinished={handleUploadFinished}
                        multiple>
                </lightning-file-upload>
                </lightning-card>

                <lightning-card title="Gst details" >
                    <lightning-file-upload
                        label="Attach receipt"
                        name="fileUploader"
                        accept={acceptedFormats}
                        record-id={recordId}
                        onuploadfinished={handleUploadFinished}
                        multiple>
                </lightning-file-upload>
                </lightning-card>
            </span>
            </div>

            <div class="slds-col slds-size_2-of-2" style="width: 300px;">
                    <lightning-input label="Email Id" name="Email_Id__c" type="text" value={formFields.Email_Id__c} onchange={changeHandler}></lightning-input>
                    <lightning-input label="Pan No" name="Pan_Number__c" type="text" value={formFields.Pan_Number__c} onchange={changeHandler}></lightning-input>
                    <lightning-input label="Gst No" name="Gst_Number__c" type="text" value={formFields.Gst_Number__c} onchange={changeHandler}></lightning-input>
                <lightning-card title="Pan card details" >
                    <lightning-file-upload
                        label="Attach receipt"
                        name="fileUploader"
                        accept={acceptedFormats}
                        record-id={recordId}
                        onuploadfinished={handleUploadFinished}
                        multiple>
                </lightning-file-upload>
                </lightning-card>
                </div>
                
            </div>
            </lightning-card>
            <lightning-button label="Submit" variant="brand" onclick={handleSave} ></lightning-button>
            &nbsp; &nbsp;
            <lightning-button label="Cancel" variant="brand" onclick={handleCancel} ></lightning-button>
</div>

<!-- modal footer start-->
<!-- <footer class="slds-modal__footer"> -->
<!-- <button class="slds-button slds-button_neutral" onclick={hideModalBox}>Cancel</button> -->
<!-- <button class="slds-button slds-button_neutral" onclick={hideModalBox}>Submit</button> -->
<!-- </footer> -->

</div>
</section>
<div class="slds-backdrop slds-backdrop_open"></div>
</template>
<!-- modal end -->
</template>

js:
js:
import { LightningElement,track,api } from 'lwc';
import {ShowToastEvent} from 'lightning/platformShowToastEvent';
import { createRecord } from 'lightning/uiRecordApi';
import INNAD_GASSTATION_OBJECT from '@salesforce/schema/INNAD_Gas_Station__c';

import OWNER_NAME_FIELD from '@salesforce/schema/INNAD_Gas_Station__c.Owner_Name__c';
import PHONE_NO_FIELD from '@salesforce/schema/INNAD_Gas_Station__c.Phone_No__c';
import EMAIL_ID_FIELD from '@salesforce/schema/INNAD_Gas_Station__c.Email_Id__c';
import PAN_NO_FIELD from '@salesforce/schema/INNAD_Gas_Station__c.Pan_Number__c';

export default class GasStation extends LightningElement {

    formFields = {
        Firm_Name__c:'',
        Owner_Name__c:'',
        Phone_No__c:'',
        Email_Id__c:'',
        Pan_Number__c:'',
        Gst_Number__c:''
    }
    changeHandler(event){
        const {value, name} = event.target
        this.formFields = { ...this.formFields, [name]:value}
    }

    handleSave(){
        const fields ={}
        fields[OWNER_NAME_FIELD.fieldApiName] = this.formFields.Owner_Name__c
        console.log(this.formFields.Owner_Name__c)
        fields[PHONE_NO_FIELD.fieldApiName] = this.formFields.Phone_No__c
        console.log(this.formFields.Owner_Name__c)
        fields[EMAIL_ID_FIELD.fieldApiName] = this.formFields.Email_Id__c
        console.log(this.formFields.Owner_Name__c)
        fields[PAN_NO_FIELD.fieldApiName] = this.formFields.Pan_Number__c
        console.log(this.formFields.Owner_Name__c)
        let recordInput = { apiName: INNAD_GASSTATION_OBJECT.objectApiName, fields}
        createRecord(recordInput).then(result=>{
            this.formFields={}
            console.log('Record created ID', JSON.stringify(result.id))
        }).catch(error=>{
            console.error(error)
        })
    }

    @track isShowModal = false;

    showModalBox() {  
        this.isShowModal = true;
    }
    
    hideModalBox() {  
        this.isShowModal = false;
    }
    
    handleCancel() {  
        this.isShowModal = false;
    }

    @api recordId;
    get acceptedFormats() {
        return ['.pdf', '.png','.jpg','.jpeg'];
    }
    handleUploadFinished(event) {
        // Get the list of uploaded files
        const uploadedFiles = event.detail.files;
        let uploadedFileNames = '';
        for(let i = 0; i < uploadedFiles.length; i++) {
            uploadedFileNames += uploadedFiles[i].name + ', ';
        }
        this.dispatchEvent(
            new ShowToastEvent({
                title: 'Success',
                message: uploadedFiles.length + ' Files uploaded Successfully: ' + uploadedFileNames,
                variant: 'success',
            }),
        );
    }    
}

<?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__HomePage</target>
        <target>lightning__RecordPage</target>
        <target>lightning__Tab</target>
    </targets>
</LightningComponentBundle>

i newly create the application.i added that in home page.in home page i need to need the template region.so i go to edit page and and changing the template but unfortunately while changing the template it comes in chinese language .kindly someone help me to fix this.

User-added image

User-added image

User-added imageUser-added image

scenario: how do prevent the duplicate record:

already i tried in list it workedmfor my practice i am trying map.i facing problem kindly someone help me

handler class:
 public static void preventDuplicate1(Map<Id,Account> recmap){
         Map<Id,Account> mapacc =  new Map<Id,Account>([select Id,Name from Account where Name =:recmap.values().Name]);
         system.debug(mapacc.values());
         for(Account acc:mapacc.values()){
             
             if(acc.name != recmap.get(acc.Id).Name){
                 acc.Name.addError('cannot use the rename');
             }
         }
             }


trigger :
trigger AccountDescription on Account (before insert,before update,after insert,after update,before delete,after delete,after undelete) {
if(Trigger.IsBefore && Trigger.IsInsert){
        AccoutBeforeInsert.preventDuplicate1(Trigger.newMap);
    }

can anyone help this?


User-added image

User-added image

User-added image

 

I want to create the new custom field in the case object,In the custom field i need to add multiple email id.whenever the case is closed it should the email notification to the email id

kindly some one help me how to execute this scenario by using flow

i tried :
i used large text area to create the field.i'm using the flow to execute this task

i created new record trigger flow in after update.

User-added image

User-added image

User-added image

User-added image
User-added image

i'm beginner in salesforce,working in fsl project .In workOrder object there is an button called create service appointment,while clicking the button it generating the existing pdf report..i want to add the few fields(which are in the service appointment generating report fields) in the pdf report.I'm not able to identify the templates exactly.. 1.how do identify the exact template
2.how to add the new fields
kindly someone help me  
 
i want to create a custom button by using lwc,when i click the button it should create the drapdown option of templates..below the code i tried..kindly someone help me with how do i comeup with dropdown option for existing templates. eg pic i mentioned below
example
html:
<template>
  <!-- lightning button for open modal window -->
  <lightning-button variant="brand"
     label="PM Report For All Machines"
     title="PM Report For All Machines"
     onclick={openModal}
     class="slds-m-left_x-small"></lightning-button>
  <!-- modal start -->        
  <template if:true={bShowModal}>
     <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">
           <!-- modal header start -->
           <header class="slds-modal__header">
              <button class="slds-button slds-button_icon slds-modal__close slds-button_icon-inverse" title="Close" onclick={closeModal}>
                 <lightning-icon icon-name="utility:close"
                    alternative-text="close"
                    variant="inverse"
                    size="small" ></lightning-icon>
                 <span class="slds-assistive-text">Close</span>
              </button>
              <h2 id="modal-heading-01" class="slds-text-heading_medium slds-hyphenate">Modal Header with LWC</h2>
           </header>
           <!-- modal body start -->
           <div class="slds-modal__content slds-p-around_medium" id="modal-content-id-1">
              <p>Sit nulla est ex deserunt exercitation anim occaecat. Nostrud ullamco deserunt aute id consequat veniam incididunt duis in sint irure nisi. Mollit officia cillum Lorem ullamco minim nostrud elit officia tempor esse quis. Cillum sunt ad dolore
                 quis aute consequat ipsum magna exercitation reprehenderit magna. Tempor cupidatat consequat elit dolor adipisicing.
              </p>
              <p>Dolor eiusmod sunt ex incididunt cillum quis nostrud velit duis sit officia. Lorem aliqua enim laboris do dolor eiusmod officia. Mollit incididunt nisi consectetur esse laborum eiusmod pariatur proident. Eiusmod et adipisicing culpa deserunt nostrud
                 ad veniam nulla aute est. Labore esse esse cupidatat amet velit id elit consequat minim ullamco mollit enim excepteur ea.
              </p>
           </div>
           <!-- modal footer start-->
           <footer class="slds-modal__footer">
              <button class="slds-button slds-button_neutral" onclick={closeModal}>Cancel</button>
           </footer>
        </div>
     </section>
     <div class="slds-backdrop slds-backdrop_open"></div>
  </template>
  <!-- modal end -->
</template>

xml:
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>54.0</apiVersion>
    <isExposed>true</isExposed>
    <targets>
        <target>lightning__AppPage</target>
        <target>lightning__HomePage</target>
        <target>lightning__RecordPage</target>
    </targets>
</LightningComponentBundle>

js:
import { LightningElement,track } from 'lwc';
export default class WorkOrderWithWoliPM extends LightningElement {
    @track bShowModal = false;
    /* javaScipt functions start */
    openModal() {    
        // to open modal window set 'bShowModal' tarck value as true
        this.bShowModal = true;
    }
    closeModal() {    
        // to close modal window set 'bShowModal' tarck value as false
        this.bShowModal = false;
    }
    /* javaScipt functions end */
}


 

I want to create a button(detail page link)in the objA and i have to add a report templates in that button.how do i that?Kindly someone help me..report templates are already existing one.

 

 

requirements:
in workorder object two fields(service(date/time).actual(formula(date/time)).
service field should be populated with actual field(if actual have value).
service field should be editable.
 i tried the below code.problem is actual field populated with service field.i want to update the populated service field value.for my code it's not working can any one suggest me. how to do proceed further.

public static void serviceinstall(Map<Id,WorkOrder> newMap){
    List<WorkOrder> workOrderUpdateList = new List<WorkOrder>();
    Map<ID, WorkOrder> workOrderMap = new Map<ID, WorkOrder>([SELECT Id, Actual_Install_Date_c,Service_Installation_Date_c FROM WorkOrder Where Id IN: newMap.keySet()]);
    for(WorkOrder wo1: workOrderMap.values()){ 
       // WorkOrder wo1 = workOrderMap.get(wo.Id);            
        if(wo1.Actual_Install_Date__c != NULL){
           wo1.Service_Installation_Date_c = wo1.Actual_Install_Date_c;
        }
        workOrderUpdateList.add(wo1);
        system.debug('workorder='+workOrderUpdateList.size());     
    }
    if(!workOrderUpdateList.isEmpty()){
        RecursiveTriggerHandler.IsserviceInstallDate = True;
        DatabaseUtils.updateSObjects(workOrderUpdateList, false) ; 
    }

protected sss void afterInsert(){     
        if(RecursiveTriggerHandler.IsserviceInstallDate == true) return;
        WorkOrderBusinessLogic.serviceinstall(newMap);
    }
protected override void afterUpdate(){
        WorkOrderBusinessLogic.serviceinstall(newMap);

kindly someone help me

 
Create a picklist field with two value Type1, Type2 in contact object. Picklist fields name = 'Secondary Contact Type', make it mandatory When a user creates a Contact record, if User selects value in Secondary Contact Type a new record in the Object called Secondary Contact should be created.
Create two record type for Secondary Contact object namely Sales and Service.
If Type1 selected - Secondary Contact of record type 'Sales' should be created
If Type2 selected - Secondary Contact of record type 'Service' should be created
Secondary Contact created should be seen in Contact records detail page as a lookup field.

trigger contactRecordValues on Contact (after insert) { List<Secondary_Contact1__c> sectlist = new List<Secondary_Contact1__c>(); for(Contact con:Trigger.new){ if(con.Secondary_Contact_Type__c=='Type1'){ Secondary_Contact1__c seccon = new Secondary_Contact1__c(); seccon.RecordTypeId = con.Secondary_Contact1__c; sectlist.add(seccon);
}
}
if(sectlist.size()>0){ insert sectlist; }
}

above code is i tried...kindly someone help meUser-added imageUser-added imageUser-added imageUser-added image
 
User-added image
iinstalled vs code and try to open while i facing the above error.kindly someobe help me
i try to create a project while i'm facing this error..
"command:sfdx:create project with manifeast resulted in error(command 'sfdx:force.project.with.manifeast.create".

Moreover.i checked wth sfdx version it's not working shown some error.kindly someone help me..thanks in advance.User-added image
i'm not able to complete the challenge..i added the code below

code:
public class Accounts extends fflib_SObjectDomain {
   public Accounts(List<Account> sObjectList)
   {
       super(sObjectList);
   }
    
     public class Constructor implements fflib_SObjectDomain.IConstructable {
        public fflib_SObjectDomain construct(List<sObject> sObjectList) {
            return new Accounts(sObjectList);
        }
     }
    
    public override void onApplyDefaults()
    {
        // Apply defaults to account
        for(Account acc: (List<Account>) Records)
        {
            if(acc.Description == null)
            {
            acc.Description = 'Domain classes rock!';
            }
        }
    }
    
    public override void handleBeforeInsert()
    {
        onApplyDefaults();
    }
    
    public override void onBeforeUpdate(Map<Id,sObject> existingRecords) {
        String rock = 'Domain classes rock!';
        List<Account> updatedAccounts = new List<Account>();
        for(Account acc : (List<Account>) Records) {                  
            acc.AnnualRevenue = rock.getLevenshteinDistance(acc.Description);
            updatedAccounts.add(acc);
        }
       
       fflib_SObjectUnitOfWork uow = new fflib_SObjectUnitOfWork(new Schema.SObjectType[] { Account.SObjectType });
        uow.registerDirty(updatedAccounts);
    }    
}

trigger:
trigger AccountsTrigger on Account ( 
    after delete, after insert, after update, after undelete, before delete, before insert, before update) 
 {
     fflib_SObjectDomain.triggerHandler(Accounts.class);
}

errorkindly assit me to complete this challenge
I'm not able to clear the challenge ,kindly help me to pass  the challenge .Below i adding my code
warehousecalloutservice:
public with sharing class WarehouseCalloutService implements Queueable, Database.AllowsCallouts {  
   private static final String WAREHOUSE_URL = 'https://th-superbadge-apex.herokuapp.com/equipment';    
   public static void runWarehouseEquipmentSync(){
       Http http = new Http();
       HttpRequest request = new HttpRequest();
       request.setMethod('GET');
       request.setEndpoint(WAREHOUSE_URL);
       HttpResponse response = http.send(request);
       if(response.getStatusCode() == 200) {
           List<Object> jsonResponse = (List<Object>)JSON.deserializeUntyped(response.getBody());
           system.debug('~~ '+jsonResponse);
           List<Product2> productList = new List<Product2>();
           for(Object ob : jsonResponse) {
               Map<String,Object> mapJson = (Map<String,Object>)ob;
               Product2 pr = new Product2();
               pr.Replacement_Part__c = (Boolean)mapJson.get('replacement');
               pr.Name = (String)mapJson.get('name');
               pr.Maintenance_Cycle__c = (Integer)mapJson.get('maintenanceperiod');
               pr.Lifespan_Months__c = (Integer)mapJson.get('lifespan');
               pr.Cost__c = (Decimal) mapJson.get('lifespan');
               pr.Warehouse_SKU__c = (String)mapJson.get('sku');
               pr.Current_Inventory__c = (Double) mapJson.get('quantity');
               productList.add(pr);
           }            
           if(productList.size()>0)
               upsert productList;
       }         
   }
   }    

warehousecalloutserviceMock:
@isTest
global class WarehouseCalloutServiceMock implements HttpCalloutMock {
    // implement http mock callout
    global static HttpResponse respond(HttpRequest request){
        System.assertEquals('https://th-superbadge-apex.herokuapp.com/equipment', request.getEndpoint());
 

        System.assertEquals('GET', request.getMethod());

        // Create a fake response
 

        HttpResponse response = new HttpResponse();
 

        response.setHeader('Content-Type', 'application/json');
 

        response.setBody('[{"_id":"55d66226726b611100aaf741","replacement":false,"quantity":5,"name":"Generator 1000 kW","maintenanceperiod":365,"lifespan":120,"cost":5000,"sku":"100003"}]'); 
        response.setStatusCode(200);
        return response;
 
    } 
}

warehousecalloutservicetest
@isTest 
private class WarehouseCalloutServiceTest {    
    @isTest   
  static void testWareHouseCallout(){
        Test.startTest(); 
        // implement mock callout test here
        Test.setMock(HTTPCalloutMock.class, new WarehouseCalloutServiceMock());
    WarehouseCalloutService.runWarehouseEquipmentSync();
        System.enqueueJob(new WarehouseCalloutService());
        Test.stopTest();
        System.assertEquals(1, [SELECT count() FROM Product2]);
    }     
}

User-added image
i'm doing the apex specialist superbadge
https://trailhead.salesforce.com/en/content/learn/superbadges/superbadge_apex

i'm not able to clear the challenge kindly someone help
WarehouseCalloutService:apxc:
public with sharing class WarehouseCalloutService implements Queueable {
    private static final String WAREHOUSE_URL = 'https://th-superbadge-apex.herokuapp.com/equipment';
    
    //class that makes a REST callout to an external warehouse system to get a list of equipment that needs to be updated.
    //The callout’s JSON response returns the equipment records that you upsert in Salesforce. 
    
    @future(callout=true)
    public static void runWarehouseEquipmentSync(){
        Http http = new Http();
        HttpRequest request = new HttpRequest();
        
        request.setEndpoint(WAREHOUSE_URL);
        request.setMethod('GET');
        HttpResponse response = http.send(request);
        
        List<Product2> warehouseEq = new List<Product2>();
        
        if (response.getStatusCode() == 200){
            List<Object> jsonResponse = (List<Object>)JSON.deserializeUntyped(response.getBody());
            System.debug(response.getBody());
            
            //class maps the following fields: replacement part (always true), cost, current inventory, lifespan, maintenance cycle, and warehouse SKU
            //warehouse SKU will be external ID for identifying which equipment records to update within Salesforce
            for (Object eq : jsonResponse){
                Map<String,Object> mapJson = (Map<String,Object>)eq;
                Product2 myEq = new Product2();
                myEq.Replacement_Part__c = (Boolean) mapJson.get('replacement');
                myEq.Name = (String) mapJson.get('name');
                myEq.Maintenance_Cycle__c = (Integer) mapJson.get('maintenanceperiod');
                myEq.Lifespan_Months__c = (Integer) mapJson.get('lifespan');
                myEq.Cost__c = (Integer) mapJson.get('cost');
                myEq.Warehouse_SKU__c = (String) mapJson.get('sku');
                myEq.Current_Inventory__c = (Double) mapJson.get('quantity');
                myEq.ProductCode = (String) mapJson.get('_id');
                warehouseEq.add(myEq);
            }
            
            if (warehouseEq.size() > 0){
                upsert warehouseEq;
                System.debug('Your equipment was synced with the warehouse one');
            }
        }
    }
    
    public static void execute (QueueableContext context){
        runWarehouseEquipmentSync();
    }
    
}

anonymous window:
WarehouseCalloutService.runWarehouseEquipmentSync();
User-added imageUser-added image
 
initially it showed the variable doesn't exist error  cloned case id(line 18) i created a new field in cloned case id(lookup relationship with equipment) in maintenancerequest(case) object.
trigger:
trigger MaintenanceRequest on Case (before update, after update) {
    if(Trigger.isAfter) MaintenanceRequestHelper.updateWorkOrders(Trigger.New);
}
class:
public with sharing class MaintenanceRequestHelper {
    public static void updateWorkOrders(List<Case> caseList) {
        List<case> newCases = new List<Case>();
        Map<String,Integer> result=getDueDate(caseList);
        list<Equipment_Maintenance_Item__c> itemsListToinsert= new list<Equipment_Maintenance_Item__c>();
      Map<String,list<Equipment_Maintenance_Item__c>> resultItmes=getMaintainanceItems(caseList);
        for(Case c : caseList){
            if(c.status=='closed')
                if(c.type=='Repair' || c.type=='Routine Maintenance'){
                    Case newCase = new Case();
                    newCase.Status='New';
                    newCase.Origin='web';
                    newCase.Type='Routine Maintenance';
                    newCase.Subject='Routine Maintenance of Vehicle';
                    newCase.Vehicle__c=c.Vehicle__c;
                    newCase.Equipment__c=c.Equipment__c;
                    newCase.Date_Reported__c=Date.today();
                    newcase.Cloned_Case_Id__c=c.Id;
                    if(result.get(c.Id)!=null)
                     newCase.Date_Due__c=Date.today()+result.get(c.Id);
                    else
                        newCase.Date_Due__c=Date.today();
                    newCases.add(newCase);
                }
        }        
       if(newCases.size()>0)
       {      
           insert newCases; 
           
           for(Case c : newCases){
             List<Equipment_Maintenance_Item__c> temp =  resultItmes.get(c.Cloned_Case_Id__c);
               if(temp !=null){
                    for(Equipment_Maintenance_Item__c row:temp){
                    Equipment_Maintenance_Item__c newitem = new Equipment_Maintenance_Item__c();
                        newitem.Equipment__c=row.Equipment__c;
                        newitem.Maintenance_Request__c= c.Id;
                        newitem.Quantity__c= row.Quantity__c;  
                        itemsListToinsert.add(newitem);
                        
                    }
               }
               
           }
           
           
       }
        
       if(itemsListToinsert.size()>0)
           insert itemsListToinsert;
    }
    //
    public static  Map<String,Integer> getDueDate(List<case> CaseIDs){       
       Map<String,Integer> result = new Map<String,Integer>();
        Map<Id, case> caseKeys = new Map<Id, case> (CaseIDs);        
       List<AggregateResult> wpc=[select Maintenance_Request__r.ID cID,min(Equipment__r.Maintenance_Cycle__c)cycle
                      from Equipment_Maintenance_Item__c where  Maintenance_Request__r.ID in :caseKeys.keySet() and Equipment__r.Maintenance_Cycle__c != null group by             Maintenance_Request__r.ID ];
        for(AggregateResult res :wpc){
            Integer addDays=0;
            if(res.get('cycle')!=null)
                addDays+=Integer.valueOf(res.get('cycle'));
            result.put((String)res.get('cID'),addDays);
        }
        return result;
}
    
    
     public static Map<String,list<Equipment_Maintenance_Item__c>> getMaintainanceItems(List<case> CaseIDs){       
     
       Map<String,list<Equipment_Maintenance_Item__c>> mapofMaintainanceItems = new Map<String,list<Equipment_Maintenance_Item__c>>();
        Map<Id, case> caseKeys = new Map<Id, case> (CaseIDs);        
       list<Equipment_Maintenance_Item__c> lstrec = new  list<Equipment_Maintenance_Item__c>([select id ,Maintenance_Request__c,Equipment__c,Quantity__c  
                      from Equipment_Maintenance_Item__c where  Maintenance_Request__r.ID in :caseKeys.keySet() ]);
        
         for(Equipment_Maintenance_Item__c row:lstrec){
              
                if (mapofMaintainanceItems.containsKey(row.Maintenance_Request__c)) {
                    List<Equipment_Maintenance_Item__c> temp = mapofMaintainanceItems.get(row.Maintenance_Request__c);
                        temp.add(row);
                    mapofMaintainanceItems.put(row.Maintenance_Request__c, temp);
                }
                else{
                    mapofMaintainanceItems.put(row.Maintenance_Request__c, new List<Equipment_Maintenance_Item__c> { row });
                }    
                       
         }
         
        return mapofMaintainanceItems;
}
}
    
User-added imageUser-added image
i'm beginner in trigger.i tried below code but stucked in midway..kindly someone help

trigger practiceacc on Account (after update){
    List<contact> ctlt = new List<contact>();
    set<Id> st = new set<Id>();
    for(Account acc:Trigger.new){
        st.add(acc.id);       
    }
Map<Id,Account> mapacc = new new Map<Id,Account>([Select Id,Name,Phone from contact where AccountId in:st]);
    for(Account obj1:Trigger.new){
      if(mapacc.get(obj1.Accountid).obj1=Phone)  
    }     
    update ctlt;
}
In diagnosis object created a field (causes-datatype(picklist)--fever,cough,wheezing. and in patient object created a field is called Reason(datatype-reason):My requirement : if causes is fever,it will pop up on reason as fever,if it cough reason should be cough..i don;t know how to write a code..kindly someone help me.User-added imageUser-added imageUser-added image
scenario:If the category is covid,insurance should true,
i try the below code it running without error but the insurance field is not active..kindly someone help me.below i added the codes and screenshot.

kindly someone give the correct code.
User-added imageUser-added imageUser-added image
i created a record by usig LWC and uploaded the file.But In UI it's not displaying the file for the corresponding record.Kidl someone help me

below i added the code:

<template>
   
    <lightning-button class="button" variant="brand" label="Gas station" 
    title="Gas Station"  onclick={showModalBox}>
</lightning-button>


<!-- modal start -->      
<template if:true={isShowModal}>

<!--
I Used SLDS for this code
Here is link https://www.lightningdesignsystem.com/components/modals/
--> 

<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">
<!-- modal header start -->
<header class="slds-modal__header">
<button class="slds-button slds-button_icon slds-modal__close slds-button_icon-inverse" title="Close" onclick={hideModalBox}>
<lightning-icon icon-name="utility:close" alternative-text="close" variant="inverse"
size="small" ></lightning-icon>
<span class="slds-assistive-text">Close</span>
</button>
<h2 id="modal-heading-01" class="slds-text-heading_medium slds-hyphenate" style="background-color: rgb(218, 8, 116);">New Gas station</h2>
</header>

<!-- modal body start -->
<div class="slds-modal__content slds-p-around_large" id="modal-content-id-1">
        <lightning-card>
            <div class="slds-grid slds-gutters">
            <div class="slds-col slds-size_1-of-2" style="width: 300px;">
                <span>
                <lightning-input label="Firm Name" name="Firm_Name__c" type="text" value={formFields.Firm_Name__c} onchange={changeHandler}></lightning-input>
                <lightning-input label="owner Name" name="Owner_Name__c" type="text" value={formFields.Owner_Name__c} onchange={changeHandler}></lightning-input>
                <lightning-input label="Phone Number" name="Phone_No__c" type="text" value={formFields.Phone_No__c} onchange={changeHandler}></lightning-input>               
                
                <lightning-card title="Partnership details" >
                    <lightning-file-upload
                        label="Attach receipt"
                        name="fileUploader"
                        accept={acceptedFormats}
                        record-id={recordId}
                        onuploadfinished={handleUploadFinished}
                        multiple>
                </lightning-file-upload>
                </lightning-card>

                <lightning-card title="Gst details" >
                    <lightning-file-upload
                        label="Attach receipt"
                        name="fileUploader"
                        accept={acceptedFormats}
                        record-id={recordId}
                        onuploadfinished={handleUploadFinished}
                        multiple>
                </lightning-file-upload>
                </lightning-card>
            </span>
            </div>

            <div class="slds-col slds-size_2-of-2" style="width: 300px;">
                    <lightning-input label="Email Id" name="Email_Id__c" type="text" value={formFields.Email_Id__c} onchange={changeHandler}></lightning-input>
                    <lightning-input label="Pan No" name="Pan_Number__c" type="text" value={formFields.Pan_Number__c} onchange={changeHandler}></lightning-input>
                    <lightning-input label="Gst No" name="Gst_Number__c" type="text" value={formFields.Gst_Number__c} onchange={changeHandler}></lightning-input>
                <lightning-card title="Pan card details" >
                    <lightning-file-upload
                        label="Attach receipt"
                        name="fileUploader"
                        accept={acceptedFormats}
                        record-id={recordId}
                        onuploadfinished={handleUploadFinished}
                        multiple>
                </lightning-file-upload>
                </lightning-card>
                </div>
                
            </div>
            </lightning-card>
            <lightning-button label="Submit" variant="brand" onclick={handleSave} ></lightning-button>
            &nbsp; &nbsp;
            <lightning-button label="Cancel" variant="brand" onclick={handleCancel} ></lightning-button>
</div>

<!-- modal footer start-->
<!-- <footer class="slds-modal__footer"> -->
<!-- <button class="slds-button slds-button_neutral" onclick={hideModalBox}>Cancel</button> -->
<!-- <button class="slds-button slds-button_neutral" onclick={hideModalBox}>Submit</button> -->
<!-- </footer> -->

</div>
</section>
<div class="slds-backdrop slds-backdrop_open"></div>
</template>
<!-- modal end -->
</template>

js:
js:
import { LightningElement,track,api } from 'lwc';
import {ShowToastEvent} from 'lightning/platformShowToastEvent';
import { createRecord } from 'lightning/uiRecordApi';
import INNAD_GASSTATION_OBJECT from '@salesforce/schema/INNAD_Gas_Station__c';

import OWNER_NAME_FIELD from '@salesforce/schema/INNAD_Gas_Station__c.Owner_Name__c';
import PHONE_NO_FIELD from '@salesforce/schema/INNAD_Gas_Station__c.Phone_No__c';
import EMAIL_ID_FIELD from '@salesforce/schema/INNAD_Gas_Station__c.Email_Id__c';
import PAN_NO_FIELD from '@salesforce/schema/INNAD_Gas_Station__c.Pan_Number__c';

export default class GasStation extends LightningElement {

    formFields = {
        Firm_Name__c:'',
        Owner_Name__c:'',
        Phone_No__c:'',
        Email_Id__c:'',
        Pan_Number__c:'',
        Gst_Number__c:''
    }
    changeHandler(event){
        const {value, name} = event.target
        this.formFields = { ...this.formFields, [name]:value}
    }

    handleSave(){
        const fields ={}
        fields[OWNER_NAME_FIELD.fieldApiName] = this.formFields.Owner_Name__c
        console.log(this.formFields.Owner_Name__c)
        fields[PHONE_NO_FIELD.fieldApiName] = this.formFields.Phone_No__c
        console.log(this.formFields.Owner_Name__c)
        fields[EMAIL_ID_FIELD.fieldApiName] = this.formFields.Email_Id__c
        console.log(this.formFields.Owner_Name__c)
        fields[PAN_NO_FIELD.fieldApiName] = this.formFields.Pan_Number__c
        console.log(this.formFields.Owner_Name__c)
        let recordInput = { apiName: INNAD_GASSTATION_OBJECT.objectApiName, fields}
        createRecord(recordInput).then(result=>{
            this.formFields={}
            console.log('Record created ID', JSON.stringify(result.id))
        }).catch(error=>{
            console.error(error)
        })
    }

    @track isShowModal = false;

    showModalBox() {  
        this.isShowModal = true;
    }
    
    hideModalBox() {  
        this.isShowModal = false;
    }
    
    handleCancel() {  
        this.isShowModal = false;
    }

    @api recordId;
    get acceptedFormats() {
        return ['.pdf', '.png','.jpg','.jpeg'];
    }
    handleUploadFinished(event) {
        // Get the list of uploaded files
        const uploadedFiles = event.detail.files;
        let uploadedFileNames = '';
        for(let i = 0; i < uploadedFiles.length; i++) {
            uploadedFileNames += uploadedFiles[i].name + ', ';
        }
        this.dispatchEvent(
            new ShowToastEvent({
                title: 'Success',
                message: uploadedFiles.length + ' Files uploaded Successfully: ' + uploadedFileNames,
                variant: 'success',
            }),
        );
    }    
}

<?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__HomePage</target>
        <target>lightning__RecordPage</target>
        <target>lightning__Tab</target>
    </targets>
</LightningComponentBundle>

User-added image
User-added image

I want to create the new custom field in the case object,In the custom field i need to add multiple email id.whenever the case is closed it should the email notification to the email id

kindly some one help me how to execute this scenario by using flow

i tried :
i used large text area to create the field.i'm using the flow to execute this task

i created new record trigger flow in after update.

User-added image

User-added image

User-added image

User-added image
User-added image

Create a picklist field with two value Type1, Type2 in contact object. Picklist fields name = 'Secondary Contact Type', make it mandatory When a user creates a Contact record, if User selects value in Secondary Contact Type a new record in the Object called Secondary Contact should be created.
Create two record type for Secondary Contact object namely Sales and Service.
If Type1 selected - Secondary Contact of record type 'Sales' should be created
If Type2 selected - Secondary Contact of record type 'Service' should be created
Secondary Contact created should be seen in Contact records detail page as a lookup field.

trigger contactRecordValues on Contact (after insert) { List<Secondary_Contact1__c> sectlist = new List<Secondary_Contact1__c>(); for(Contact con:Trigger.new){ if(con.Secondary_Contact_Type__c=='Type1'){ Secondary_Contact1__c seccon = new Secondary_Contact1__c(); seccon.RecordTypeId = con.Secondary_Contact1__c; sectlist.add(seccon);
}
}
if(sectlist.size()>0){ insert sectlist; }
}

above code is i tried...kindly someone help meUser-added imageUser-added imageUser-added imageUser-added image
 
i'm doing the apex specialist superbadge
https://trailhead.salesforce.com/en/content/learn/superbadges/superbadge_apex

i'm not able to clear the challenge kindly someone help
WarehouseCalloutService:apxc:
public with sharing class WarehouseCalloutService implements Queueable {
    private static final String WAREHOUSE_URL = 'https://th-superbadge-apex.herokuapp.com/equipment';
    
    //class that makes a REST callout to an external warehouse system to get a list of equipment that needs to be updated.
    //The callout’s JSON response returns the equipment records that you upsert in Salesforce. 
    
    @future(callout=true)
    public static void runWarehouseEquipmentSync(){
        Http http = new Http();
        HttpRequest request = new HttpRequest();
        
        request.setEndpoint(WAREHOUSE_URL);
        request.setMethod('GET');
        HttpResponse response = http.send(request);
        
        List<Product2> warehouseEq = new List<Product2>();
        
        if (response.getStatusCode() == 200){
            List<Object> jsonResponse = (List<Object>)JSON.deserializeUntyped(response.getBody());
            System.debug(response.getBody());
            
            //class maps the following fields: replacement part (always true), cost, current inventory, lifespan, maintenance cycle, and warehouse SKU
            //warehouse SKU will be external ID for identifying which equipment records to update within Salesforce
            for (Object eq : jsonResponse){
                Map<String,Object> mapJson = (Map<String,Object>)eq;
                Product2 myEq = new Product2();
                myEq.Replacement_Part__c = (Boolean) mapJson.get('replacement');
                myEq.Name = (String) mapJson.get('name');
                myEq.Maintenance_Cycle__c = (Integer) mapJson.get('maintenanceperiod');
                myEq.Lifespan_Months__c = (Integer) mapJson.get('lifespan');
                myEq.Cost__c = (Integer) mapJson.get('cost');
                myEq.Warehouse_SKU__c = (String) mapJson.get('sku');
                myEq.Current_Inventory__c = (Double) mapJson.get('quantity');
                myEq.ProductCode = (String) mapJson.get('_id');
                warehouseEq.add(myEq);
            }
            
            if (warehouseEq.size() > 0){
                upsert warehouseEq;
                System.debug('Your equipment was synced with the warehouse one');
            }
        }
    }
    
    public static void execute (QueueableContext context){
        runWarehouseEquipmentSync();
    }
    
}

anonymous window:
WarehouseCalloutService.runWarehouseEquipmentSync();
User-added imageUser-added image
 
i'm beginner in trigger.i tried below code but stucked in midway..kindly someone help

trigger practiceacc on Account (after update){
    List<contact> ctlt = new List<contact>();
    set<Id> st = new set<Id>();
    for(Account acc:Trigger.new){
        st.add(acc.id);       
    }
Map<Id,Account> mapacc = new new Map<Id,Account>([Select Id,Name,Phone from contact where AccountId in:st]);
    for(Account obj1:Trigger.new){
      if(mapacc.get(obj1.Accountid).obj1=Phone)  
    }     
    update ctlt;
}
In diagnosis object created a field (causes-datatype(picklist)--fever,cough,wheezing. and in patient object created a field is called Reason(datatype-reason):My requirement : if causes is fever,it will pop up on reason as fever,if it cough reason should be cough..i don;t know how to write a code..kindly someone help me.User-added imageUser-added imageUser-added image
scenario:If the category is covid,insurance should true,
i try the below code it running without error but the insurance field is not active..kindly someone help me.below i added the codes and screenshot.

kindly someone give the correct code.
User-added imageUser-added imageUser-added image
i'm trying to generate the invoice using visual force but getting this error System.QueryException: List has more than 1 row for assignment to SObject..kindly someone assist me.below i mention the code

apex class:

global with sharing class CustomerController {
    
    public Customer__c cust {get;set; }
    
    public CustomerController(){
        cust = [Select Name,
                Delivery_Address__c,
                Phone__c,
                Product_cost__c,
                Product_Name__c,
                Delivery_cost__c,
                Total_cost__c
                from Customer__c];
    }
}


VF page:
<apex:page Controller="CustomerController">
        <apex:pageBlock >
          <apex:pageBlockSection title="Invoice">
             <apex:outputText value="{!cust.Name}"/><br/>
             <apex:outputText value="{!cust.Delivery_Address__c}"/><br/>
             <apex:outputText value="{!cust.Phone__c}"/><br/>
             <apex:outputText value="{!cust.Product_cost__c}"/><br/>
             <apex:outputText value="{!cust.Product_Name__c}"/><br/>
             <apex:outputText value="{!cust.Delivery_cost__c}"/><br/> 
              <apex:outputText value="{!cust.Total_cost__c}"/><br/> 
           </apex:pageBlockSection>
        </apex:pageBlock>
</apex:page>

User-added image
  i'm not able to authorize the dev hub.It's taking long time to load.when i authorize in someother way using this command sfdx force:auth:device:login....it's unable to create defaut scratch org.Kindly someone help me.Below i mentioned the trailhead link

https://trailhead.salesforce.com/content/learn/projects/set-up-your-lightning-web-components-developer-tools/create-a-lightning-web-component?trail_id=build-lightning-web-components