Closed r00tr4v3n closed 4 years ago
Can you please explain in more detail and step by step what you did, what happened and what you expected (see issue template). Can you please post the output from the debug settings (see issue template). And is there any useful log output if you enable the log panel (see Window / Panels)? Please make sure you also enable debug logging.
I found a reason for the behaviour: Without the "allow note file name to be different from heading" setting the UUID turns into the expected file name within seconds.
Of course, the reason I used a uuid in the script you maybe saw was to have unique temporary name to use before QON sets one.
If you want to use your own file names you need to turn mentioned checkbox on.
How do I change the file name? I checked with the Meeting Script. Is it supposed to keep the UUID when having custom file names enabled?
/**
* Creates a new note
*
* @param text the note text
*/
void ScriptingService::createNote(QString text);
note.renameNoteFile()
to rename a note
file and note.allowDifferentFileName()
to check if it is allowed to have a
different note file name than the headline
There now is a new release, could you please test it and report if it works for you?
Thank you for the update. It seems to work but gives me trouble in combination with yaml tags or other note changing scripts:
This does call the tag hook but does not save the tags.
script.createNote(headline);
const currentNote = script.currentNote();
// rename the note file if needed
if (currentNote.allowDifferentFileName()) {
currentNote.renameNoteFile(headline);
mainWindow.buildNotesIndexAndLoadNoteDirectoryList(false, true);
}
script.tagCurrentNote("defaultTag");
In order of
maybe only call mainWindow.buildNotesIndexAndLoadNoteDirectoryList(false, true);
in the end, it has the potential to mess things up.
No, that does not change anything.
I suspect the rename operation messes up the currentNote()
function.
Maybe a hint in the docs to use renameNoteFile()
as last operation suffices for now?
I suspect the rename operation messes up the currentNote() function.
Does it? Is a note folder reload triggered for you if you call it? You could call curentNote()
again.
I've tried that but in this case the changes to the note (yaml header) are not present.
I've tried that but in this case the changes to the note (yaml header) are not present.
which changes should be present?
The entire yaml header is missing. The script is called and executed but the result seems to be overwritten.
Yaml headers? Which script are we talking about? And which part of the script? :smile:
Epsilon-note-tags: since the tag hook is called, the script shouldn't be the issue.
Why do you want add tags to a note via QOwnNotes in a tagging hook? You are supposed to only work on the note text and provide the updated note text via the return
command.
Or better question: What are you trying to achieve?
Or better question: What are you trying to achieve?
I'm just trying to ascertain if this is a bug or a wrong usage of the script api on my part (and the current meetings script). It works for fine with the correct execution order. There are two scripts: epsilon-tags and meetings with the renameFile call In combination, the yaml tags are not added to the note. I fixed that in my fork by changing the execution order to
Ah, ok. Just make sure not to do any note operations inside a tagging hook. :)
Will do, thank you!
I might have missed a setting somewhere:
Expected behaviour
If I create a new note in the main window, it has a time stamp name as expected.
Actual behaviour
If a script creates a note, it keeps the UUID. This should be replaced later on, I guess.
line
Steps to reproduce
Note 745bba82-010c-4396-a917-e8492bbb604b.md
was createdOutput from the debug section in the settings dialog
Expand
QOwnNotes Debug Information =========================== ## General Info **Current Date**: `Do. Apr. 23 13:06:00 2020` **Version**: `20.4.12` **Build date**: `Apr 21 2020` **Build number**: `701` **Platform**: `linux` **Operating System**: `Manjaro Linux` **Build architecture**: `x86_64` **Current architecture**: `x86_64` **Release**: `AUR` **Qt Version (build)**: `5.14.2` **Qt Version (runtime)**: `5.14.2` **Portable mode**: `no` **Settings path / key**: `/home/user/.config/PBE/QOwnNotes.conf` **Application database path**: `/home/user/.local/share/PBE/QOwnNotes/QOwnNotes.sqlite` **Application arguments**: `/usr/bin/QOwnNotes` **Qt Debug**: `0` **Locale (system)**: `en_US` **Locale (interface)**: *empty* **Primary screen resolution**: `1280x720` **Screen resolution(s)**: `1280x720, 1280x720` **Icon theme**: `Papirus-Adapta-Maia` **Notes in current note folder**: `37` **Calendar items**: `0` **Enabled scripts**: `1` ## Server Info **serverUrl**: *empty* **appIsValid**: `no` **notesPathExists**: *empty* **connectionErrorMessage**: *empty* ## Spellchecking **Enabled**: `true` **Selected language**: `auto` **Language codes**: `de_AT, de_BE, de_CH, de_DE, de_LI, de_LU` **Language names**: `Österreichisches Deutsch (Österreich), Deutsch (Belgien), Schweizer Hochdeutsch (Schweiz), Deutsch (Deutschland), Deutsch (Liechtenstein), Deutsch (Luxemburg)` **Application dictionaries path**: `/home/user/.local/share/PBE/QOwnNotes/dicts` ## Note folders **currentNoteFolderId**: `2` ### Note folder `default` **id**: `2` **isCurrent**: `yes` **activeTagId**: `-1` **localPath**: `/home/user/Downloads/test1` **remotePath**: `Notes` **cloudConnectionId**: `1` **isShowSubfolders**: `yes` **isUseGit**: `no` **activeNoteSubFolder name**: `test` **database file**: `/home/user/Downloads/test1/notes.sqlite` ## Cloud connections ### Cloud connection `Default` **id**: `1` **isCurrent**: `yes` **serverUrl**: *empty* **username**: *empty* ## Enabled scripts ### Script `testscript` **id**: `3` **path**: `/home/user/btsync/01_Development/05_Projects/Qt/scripts/testscript.qml` ## Settings **ActiveNoteHistoryItem** (NoteHistoryItem): `Relevant log output in the Log panel
log
[12:58:53] [scripting] loading script file: /.../scripts/testscript.qml [12:58:53] [status] Stored current note to disk [12:58:54] [status] The scripting engine was reloaded [12:58:55] [status] Stored 1 note(s) to disk