Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problem with Trailhead "Get Hands-On with New Alert, Confirm, and Prompt Modules and Components"

I can't to complete challenge "Get Hands-On with New Alert, Confirm, and Prompt Modules and Components". I'm pretty sure this challenge have a bug and I want to know I made a mistake or this is challenge have bug.

The assignment:

import { LightningElement, api } from "lwc";
export default
class recordCardQuickFiles extends LightningElement {
 @api
 recordId;
 onDeleteAllFilesButtonClick() {
  const confirmation = confirm("Are you sure you want to delete all files?");
   if (confirmation) {
      //... proceed with
     //... Apex Logic to delete Files.
    //... We will not check this comment.
    }
  }
}
  • Create a new Lightning Web component
  • Name: recordCardQuickFiles
  • Import LightningConfirm from "lightning/confirm"
  • Replace the confirm method with the LightningConfirm method
  • Message: "Are you sure you want to delete all files?"
  • Variant: "headerless"
  • Label: "Are you sure you want to delete all files?"

My solution:

import { LightningElement, api } from "lwc";
import LightningConfirm from "lightning/confirm";
export default
class recordCardQuickFiles extends LightningElement {
    @api
    recordId;
    configs = {
        Message: "Are you sure you want to delete all files?",
        Label: "Are you sure you want to delete all files?",
        Variant: "headerless"
    }
    onDeleteAllFilesButtonClick() {
        const confirmation = LightningConfirm.open(this.configs);
        if (confirmation) {
            //... proceed with
            //... Apex Logic to delete Files.
            //... We will not check this comment.
        }
    }
}

And error occured: Challenge not yet complete in your.org The Message used in the LightningConfirm method is not correct.

like image 472
Vladyslav Palamarchuk Avatar asked Jan 21 '26 20:01

Vladyslav Palamarchuk


1 Answers

The JS file for the LWC should be something like the following:

import { LightningElement, api } from "lwc";
import LightningConfirm from 'lightning/confirm';

export default
class recordCardQuickFiles extends LightningElement {
    @api
    recordId;
    onDeleteAllFilesButtonClick() {
        const confirmation = LightningConfirm.open({
            Message: 'Are you sure you want to delete all files?',
            Variant: 'headerless',
            Label: 'Are you sure you want to delete all files?'
        });
        if (confirmation) {
            //... proceed with
            //... Apex Logic to delete Files.
            //... We will not check this comment.
        }
    }
}

I hope that helps. Thanks!

like image 118
CristianReinoso Avatar answered Jan 23 '26 10:01

CristianReinoso