You need to sign in to do that
Don't have an account?
jrv
How to update result from wired function?
I'm using a wired function to pull rows from a custom object, but I'm not sure how to edit the response. This is what I have now:
From looking over a few sources online it seems the returned data is not editable and the suggestion was to clone the data by doing something like this:
This unfortunately gives me the following error when the searchSmartTasks function is called:
[Assert Violation: Invalid template iteration for value `[object Object]` in [object:vm undefined (46)]. It must be an array-like object and not `null` nor `undefined`.]
@wire(searchSmartTasks, { smartTaskName: '$smartTaskName', calendarValue: '$calendarValue',}) searchSmartTasks({ error, data }) { if (data) { for(let i = 0; i < this.data.length; i++) { this.data[i].classStatus = 'green'; } } else if (error) { this.error = error; console.log(error); } }My SmarTask object doesn't have a field named classStatus, so I'm trying to append it to the response, so I can access it in my view like this:
<ul> <template for:each={smartTasks} for:item="smartTask"> <li key={smartTask.Id}> {smartTask.classStatus} </li> </template> </ul>The above doesn't work. Any ideas?
From looking over a few sources online it seems the returned data is not editable and the suggestion was to clone the data by doing something like this:
// ADDED THIS LINE @track smartTasks = []; @wire(searchSmartTasks, { smartTaskName: '$smartTaskName', calendarValue: '$calendarValue',}) searchSmartTasks({ error, data }) { if (data) { // ADDED THIS LINE this.smartTasks = {...data}; for(let i = 0; i < this.smartTasks.length; i++) { this.smartTasks[i].classStatus = 'green'; } } else if (error) { this.error = error; console.log(error); } }
This unfortunately gives me the following error when the searchSmartTasks function is called:
[Assert Violation: Invalid template iteration for value `[object Object]` in [object:vm undefined (46)]. It must be an array-like object and not `null` nor `undefined`.]
--
Magulan Duraipandian
www.infallibletechie.com
On the Apex side I'm actually just returning a List like this:
Also tried setting this.smartTasks to data.data, but no luck. Any other ideas?