Issue accessing `instanceValues` via event handler defined on list view

Hi,

I think I found a bug, preventing a fairly simple and common use case.

The listview is used to display data, edit the data and then update the database.
When the switch1 is changed, the instanceValues are updated. That's the expected behavior.

Now, we want to parse the data and update the database via JS script.
When manually executed, the script works well and returns the data.

However, when the JS script query1 is triggered via an event (change of switch1), the script returns undefined.

So, it's not possible to use the data of instanceValues.

Any thoughts?

Regards,

I just ran into the same issue. @andoliveyou any suggestions?

Hi @MicExpert have you figured out a workaround to this?

I use a transformer as a buffer to parse the data between my objects and instance values. This approach allowed me to get my process working.

Regards,

1 Like

Hey @MicExpert - thanks for documenting this issue and for sharing a reasonable workaround, as well! :slightly_smiling_face:

I'll file a bug internally, talk to the team, and provide an update here as soon as I have news to share.

Having exactly the same issue here. Disappointing that a bug which clearly impacts a major component still hasn’t been repaired.

In my case, I have a javascript query which syncs the values being populated in a listview, with a variable:

let instanceValues = listView19.instanceValues;
console.log(instanceValues)
let currentData = await LegalAgreementToEdit.value;
instanceValues.forEach(v => {
currentData.fields_meta_data[v.primaryKey].wordDocumentTag = v.textInput45;
currentData.fields_meta_data[v.primaryKey].definition = v.textInput46;
});
await LegalAgreementToEdit.setValue(currentData);

When I manually execute this query, it works fine and the instanceValues are logged in the console. When I trigger this query via the change event handler on my input fields within the listview, the query fails and console logs undefined. Can you please provide an update?

@Darren any updates on this? It’s causing a big headache? When using variables, would there be any workaround?

Thanks for the bump, @FloodMatt! I hear you and understand the frustration, given the fact that this should just work without the need for tweaks or hacks. There hasn't been any significant movement internally outside of scoping out the necessary work, but I'll pass on your feedback.

In the meantime, though, there is a relatively simple workaround. Instead of directly referencing listview19.instanceValues within your JS query, you can instead create a new transformer that simply returns listview19.instanceValues and then reference that transformer instead.

This is the same pattern that @MicExpert described above, which should certainly work for you. Let me know if you have any questions!

1 Like

So, strangely I had an app that suddenly broke because of the above. I had been able to refer to instanceValues from within a jsquery, and from one day to the other this stopped working. I have now applied the transformer workaround, but just concerned about other apps I have that worked before and now may have silently broken.

1 Like