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

How do I get the "notes" (text) of a handout with API in the new engine?

Hi! So I need to get at the content of a player handout using API, but within the context of the new engine (formerly known as "jumpgate"). This is the barebones test script so far... on("change:handout", function(obj, prev) { // Get the name & ID of the handout being changed var sID = obj.get("_id")||""; var sNm = obj.get("name")||"[NO NAME FOUND]"; var sNts = obj.get("notes")||"[NO NOTES FOUND]"; if(sNm.indexOf("Test Handout") > -1 && sID != "") { let sSay1 = "/w gm **ID:** "+sID; let sSay2 = "/w gm **NAME:** "+sNm; let sSay3 = "/w gm **CONTENTS:** "+sNts; sendChat("API",sSay1); sendChat("API",sSay2); sendChat("API",sSay3); } }); It reports the ID of the handout and the name of the handout just fine. But it always reports the "notes" of the handout as not found (e.g., the  "[NO NAME FOUND]" result I put in as a default value) , even though there are about two paragraphs of content in the actual handout in question. Any idea what's going on? Did Roll20 change the name of the "notes" property? I have no idea if they did or not, as I have never needed to access the content of a handout before (under the old engine). I just looked up the names of the various properties of a handout object under the wiki documentation. What am I doing wrong? Thanks in advance for your help! Michael
1764829787
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
This isn't affected by jumpgate. The notes, gm notes, and bio are blobs. You have always needed to get them asynchronously. See the wiki for more information . I typically use an async wrapper function, getNotes, to work with these. const getNotes = function (prop,obj) {   return new Promise((resolve, reject) => {     obj.get(prop, (p) => {       resolve(p);     });   }); }; And then you'd use it like so: on("change:handout", async function(obj, prev) { // Get the name & ID of the handout being changed var sID = obj.get("_id")||""; var sNm = obj.get("name")||"[NO NAME FOUND]"; var sNts = (await getNotes('notes',obj))||"[NO NOTES FOUND]"; if(sNm.indexOf("Test Handout") > -1 && sID != "") { let sSay1 = "/w gm **ID:** "+sID; let sSay2 = "/w gm **NAME:** "+sNm; let sSay3 = "/w gm **CONTENTS:** "+sNts; sendChat("API",sSay1); sendChat("API",sSay2); sendChat("API",sSay3); } }); Note the async flag on the function and the await used with the getNotes call.
1764893307

Edited 1764894103
Thanks, Scott! I will try that. Much appreciated! Scott C.  said: This isn't affected by jumpgate. The notes, gm notes, and bio are blobs. You have always needed to get them asynchronously.  See the wiki for more information . I typically use an async wrapper function, getNotes, to work with these. [snip] EDIT: Worked great! Thanks again, Scott. And for the link. Gonna have to read up on that to understand it better. lol