Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Adding handouts to a folder

I wrote a script that *mostly* works. The intent is that it is supposed to find a folder named "....." and create 100 handouts within it, named "....". It creates the handouts at the bottom of the journal, not in the "....." folder. Can somebody see what is wrong? //Make 100 Handouts with the name "...." in the folder named "....." on("chat:message", function(msg){ if(msg.type=="api" && msg.content=="!ManyHandouts"){ for (let i = 0; i < 100; i++) { var folderName = "....."; var handoutName = "...."; var handout = createObj("handout",{ name: handoutName }); } handout.set("notes",makeHTMLNote()); // Find the folder var folder = findObjs({ _type: "handout", name: folderName })[0]; // Move the handout into the folder if the folder exists if (folder) { handout.set("infolder", folder.id); sendChat("API", "Handout '" + handoutName + "' created and moved to folder '" + folderName + "'"); } else { sendChat("API", "Folder '" + folderName + "' not found."); } } }) function makeHTMLNote(){ var body = `<div>foo</div><div>.</div><div>.</div>foo`; return body; }
1755183367
timmaugh
Forum Champion
API Scripter
Unfortunately (or, fortunately, if you look at the implementation) the folder structure can be read by the API, but not written... at least at this point... so what you're trying to do just can't be done, yet.