MetaEdit plugin

I’m working on a version that supports adding elements to list items in the frontmatter.
Until then, it’s currently not supported. QuickAdd has a feature that allows you to do this, though. You use the Insert After feature in a capture.

1 Like

I am getting a console error that was able to trace back to this plugin. Just wanted to report it here before filing on GitHub.

Thank you!

Can anyone suggest a way to add the current title of a note as an alias, so that when I change the title, I still have a way of referring to (and autocompleting on) the title before the change? I was hoping that {{title}} would work, but I can’t see how.

Are you doing some kind of scripting or templating to make this work? Has the note been created? Is this regarding many notes, or just one or two? Or, do you want some automatic workflow for it?

Legitimate questions! Definitely this is far already existing files. I’m not looking to automate this. It would mostly be one or two at a time. But even so, it would be great to just be able to have a hot key to run this. At the same time, as long as I’m getting error if there is already an existing file, it might be simpler just to use Templater with a hot key that inserts {{title}}.

This can be done in a few lines of code:

const currentFile = app.workspace.getActiveFile()
if (!currentFile) {
  return new Notice("No active file");
}
await app.plugins.plugins.metaedit.api.createYamlProperty("alias", currentFile.basename, currentFile)

You can use Templater or QuickAdd to activate the code - depending on your preferences :slight_smile:

Thanks, but I’m clearly in over my head, since I don’ t understand what “activate the code” refers to. :person_shrugging:

Is there any way to have the date automatically update to today’s when the file is moved across lanes in kanban helper?

I’d love to have it update datestarted with a date when moved to doing and datefinished when moving to completed.

1 Like

was there a update related to editing task and kanbans? i really like such a feature but can’t find anything

Hi,

When I specify that a property is “multi” (or I’ve selected the “all multi” option) - the value gets wrapped in “[ ]”.

Even if there is only one value available for the property.

I want:

Property: Value

But when multi is involved, it gives me:

Property: [Value]

Hi.
TL:DR Before I get lost in a rabbit hole of research, would it theoretically be possible to use MetaEdit to automate appending a new value to a list of values in a specific field in a different note that you specify (not the current one)?

What I really want to try and achieve is to use fields with list values (multi in MetaEdit parlance) across several notes so that they get populkated in the following way:

Say you have two fields of “offspring” and “parents”

I want to be in one note and tell it to append a note link to the “offspring” field of the current note and at the same time append the current note as a link to the “parent” field in the note being linked to from the current note.

It sounds like there should be a way (albeit complicated, and presumably using Buttons) and if there is then I’m willing to try and put the time in to get it to work… but I’m not big on coding and before I start banging my head against a code wall I thought I’d ask here.

One thing I’m not sure of is whether the MetaEdit API allows appending a specific value to a current field which may or may not already have a list of values.

Curious. Does this make a difference? As far as I could work out this simply means that Obsidian recognises that the field can have a list of values. If there is only one, presumably that still works just the same as not having the brackets there (in terms of dataview searches, etc)?

I also thought the point of using multi was specifically so that it DID do this?

Hi, it is. I have done it mixing QuickAdd macros and metaEdit API.

This is for instance, the macro I use to create a new task which is a subtask of the current file. It will append the new task name to an array in the master task, and in the subtask also a reference to the master.

I know I have a hell with promises/async/await, but bear with me, I’m not a js dev.

module.exports = async (params) => {
  const {
    app,
    quickAddApi: { yesNoPrompt, inputPrompt, executeChoice },
  } = params;
  const { update, getPropertyValue } = app.plugins.plugins['metaedit'].api;

  const master = app.workspace.getActiveFile();
  var deps = await getPropertyValue('depends-on', master);
  if (!deps) {
    deps = [];
  }
  if ((await getPropertyValue('type', master)) != 'task') {
    await yesNoPrompt('Current file is not task type');
    return;
  }

  const name = await inputPrompt('Subtask Name');
  deps.push(name);

  const masterOps = [
    update('depends-on', `[${deps.toString()}]`, master),
    executeChoice('log-task-event', {
      'Log Event': `Created subtask: [[${name}]]`,
    }),
  ];

  await Promise.all(masterOps);
  Promise.all([executeChoice('create-new-task', { Name: name })]).then(
    async () => {
      const dep = app.vault.getAbstractFileByPath(`tasks/backlog/${name}.md`);
      await executeChoice('log-task-event-to-inactive-file', {
        'File Path': dep.path,
        'Log Event': `Subtask of [[${master.basename}]]`,
      });
      await update('master-task', master.basename, dep);
    }
  );
};

The reason I await all the masterOps is because my create-new-task macro changes the scope to the new file and I was having a bug related to it. Anyway, I’m paid for coding other stuff and not my OCD macros, so I found that was an easy workaround.

OT: any change proposal to this hell of asyncs is well received :slight_smile: