MetaEdit icon indicating copy to clipboard operation
MetaEdit copied to clipboard

`update`ing a multi value property does not work.

Open thorlucas opened this issue 3 years ago • 3 comments

Have a file like:

---
foo: [a, b]
---

Call

await update('foo', ['a', 'c'], file);

You'll instead get:

---
foo: a,c
---

thorlucas avatar Aug 06 '21 08:08 thorlucas

Hey @thorlucas, thank you for your report.

This is not a bug. As can be seen in the documentation for update, the second parameter calls for a string.

update(propertyName: string, propertyValue: string, file: TFile | string)

At some point, I do want to be able to take in various types, though.

chhoumann avatar Aug 06 '21 08:08 chhoumann

Hi I am running into a similar issue with a field populated with an array. My note has the following metatable:

---
foo: ["a", "b", "c"]
---

by calling:

await update('foo', updatedarray, file)

my note does not update. However, if i call the following after having called update:

await getPropertyValue('foo', note)

i can see that the property value has changed to updatedarray for the metatable plugin. I am working mainy from iOS. IS that expected behaviour? PS: that 'foo' is also an argument for a dataviewjs codeblock. Not sure if it makes a difference in terms of access to editing the note's frontmatter.

melbv avatar Oct 25 '21 19:10 melbv

Just as a fyi, if useful, i found a way around this in dataviewjs: when building the string variable for the update function, I wrap each element of the array with "\"" and a coma between each wrapped element. Before passing the string as an argument to update, I then wrap again in "[" & "]". It is quite dirty but does the trick so far.

melbv avatar Oct 25 '21 19:10 melbv