Skip to main content Stream TDX Bengaluru on Salesforce+. Start learning the critical skills you need to build and deploy trusted autonomous agents with Agentforce. Register for free.

Hello

 

I have been trying for a while and can't figure out why I keep getting this error "We can’t find the correct settings for the method handleSave() in the component boatSearchResults JavaScript file. Make sure the method was created according to the requirements, using the correct event, refresh method, correct promises, toast events for success and failure using the constants, and complete error handling.

"

I've read multiple posts about this step but all the code shared use this pattern: 

const recordInputs = event.detail.draftValues.slice().map(draft => {

const fields = Object.assign({}, draft);

return { fields };

});

const promises = recordInputs.map(recordInput => updateRecord(recordInput));

Promise.all(promises).then(contacts => {

this.dispatchEvent(

new ShowToastEvent({

title: 'Success',

message: 'Contacts updated',

variant: 'success'

})

);

// Clear all draft values

this.draftValues = [];

// Display fresh data in the datatable

return refreshApex(this.contact);

}).catch(error => {

// Handle error

});

 

BUT it looks like SF edited the requirements because the current version (in the provided template code) asks for the apex method pattern: 

// notify loading

const updatedFields = event.detail.draftValues;

// Update the records via Apex

updateBoatList({data: updatedFields})

.then(() => {})

.catch(error => {})

.finally(() => {});

 

Below are my refresh and handleSave methods. Everything works from the UI but I can't figure out why it's not passing the checks. Hopefully a fresh pair of eyes can provide insight. Thanks in advance!

 

 

@api async refresh() {

this.isLoading = true;

this.notifyLoading(this.isLoading);

// Display fresh data in the datatable

await refreshApex(this.boats);

this.isLoading = false;

this.notifyLoading(this.isLoading);

}

handleSave(event) {

// notify loading

this.isLoading = true;

this.notifyLoading(this.isLoading);

//mass updating with Apex

const updatedFields = event.detail.draftValues;

//map will return an array of objects {"recordId": row.Id}

const notifyChangeIds = updatedFields.map(row => { return { "recordId": row.Id} });

// Update the records via Apex

updateBoatList({data: updatedFields})

.then(() => {

this.dispatchEvent(

new ShowToastEvent({

title: SUCCESS_TITLE,

message: MESSAGE_SHIP_IT,

variant: SUCCESS_VARIANT

})

);

getRecordNotifyChange(notifyChangeIds);

this.draftValues = [];

return this.refresh();

}).catch(error => {

this.dispatchEvent(

new ShowToastEvent({

title: CONST_ERROR, (NOTE: the requirements mentions using CONST_ERROR but the template code shows ERROR_TITLE. I've used both and can't pass the check with either)

message: error.body.message,

variant: ERROR_VARIANT

})

);

}).finally(() => {

this.isLoading = false;

this.notifyLoading(this.isLoading);

});

}

 

 
7 件の回答
読み込んでいます
0/9000