Advertisement Create a free account

API no longer triggering sheet workers

1557434978
Cassie
Roll20 Team
Greetings folks, Currently APIs are not triggering sheet workers as they should. The cause of the issue has been identified and I am working on a bug fix now. Unfortunately this will likely not be completed for before the weekend. I apologize for the inconvenience this may cause API users. Rest assured we are working to find a resolution to this issue. Thank you, Cassie
@cassie Is this resolved?
1558621309

Edited 1558621559
Cassie
Roll20 Team
Greetings Evan, I believe it has not. Can you give it a try and confirm it is working for you? Thanks, Cassie
1558711142
Cassie Could this be related to an API error that's been seen by multiple people: Error downloading scripts (probably no scripts exist for campaign.)
1558716248
Cassie
Roll20 Team
Greetings Skepickle, That's a different issue related to an infrastructure upgrade .
1558756313
So I guess that the issues still has not been resolved?  Our character sheets for our FFG SW game still is not responding.
1561064776
keithcurtis
Forum Champion
API Scripter
Hi Cassie, Is there any update on when this issue will be resolved? I'm still getting no joy on this issue .
1561141174
Cassie
Roll20 Team
Greetings, It is currently not fixed and I have asked the powers that be for an update. Sorry for the delays. - Cassie
1561144356
keithcurtis
Forum Champion
API Scripter
Thanks, Cassie!
1561299965
Michael G.
Pro
API Scripter
Is this issue the sheetworker issue or is it unrelated?
1562180471
Kenton
Roll20 Team
Hello API fans. Thanks for your patience while we work through this issue. What we're finding is inconsistencies in Sheet Workers called from the API, but I wanted to ask for your help with specific APIs and Character Sheets that are not working. We don't need every failure, but enough to fully encapsulate the scope of the issue. Please leave a comment with the API, the Character Sheet, and the error you received.
1562320625
Thanks Kenton, I'm experiencing problems with the 5E OGL sheet when toggling Global Damage Modifier via ChatSetAttr. The error message is  "GLOBALDAMAGE" "ReferenceError: update_attacks is not defined" "ReferenceError: update_attacks is not defined\n at Object.eval [as -LcY3Gj_eveqSdhNFnNf//repeating_damagemod_-LcY3bPUU4GzEMcGqZwZ//0.06484943159589673] (eval at messageHandler (evalmachine.<anonymous>:284:6), <anonymous>:4169:25)\n at _fullfillAttrReq (evalmachine.<anonymous>:259:31)\n at messageHandler (evalmachine.<anonymous>:296:6)\n at process.<anonymous> (/home/node/d20-api-server/node_modules/tiny-worker/lib/worker.js:60:55)\n at emitTwo (events.js:106:13)\n at process.emit (events.js:194:7)\n at process.nextTick (internal/child_process.js:766:12)\n at _combinedTickCallback (internal/process/next_tick.js:73:7)\n at process._tickCallback (internal/process/next_tick.js:104:9)" Cheers
1562339347

Edited 1562720420
keithcurtis
Forum Champion
API Scripter
Sheetworker API failure example API Script : ChatSetAttr Sheet : D&D5e by Roll20 Command that fails: !setattr --sel --repeating_damagemod_$0_global_damage_active_flag|1 Expected Behavior : Check referenced Global Damage modifier and activate it Actual Behavior : Checks box, but Global Damage Modifier does not actually activate. You must toggle the box manually for this to happen. More Info : The inverse of this comand: !setattr --sel --repeating_damagemod_$0_global_damage_active_flag|0 works identically: toggles box off, but does not deactivate modifier. ChatSetAttr has setting to "use sheetworkers"; this has been set to ON. This solution may be related to the D&D5e by Roll20 sheet. Similar steps do work on Shaped sheet for 5e.
1562722045
Sheetworker Failure Example API Script : ChatSetAttr Sheet : D&D5e by Roll20 Command that fails : !modbattr --silent --sel --exhaustion_level|?{Add or Subtract?|Add,+1|Subtract,-1} Expected behavior : Exhaustion level incremented by 1 (plus or minus) and description of exhaustion effects updates on character sheet (disadvantage at level 1, speed halved at level two, etc.) Actual behavior : Level increments, but nothing appears in exhaustion field except the words "No effect" (as if no exhaustion is present) and odd characters (white question marks against black background) More info : Toggling the exhaustion levels up or down manually in the sheet produces the desired description in the field. It's just not working via API.
1562889531
I can't get the 13th Age API working properly. Commands like !edie and !setup do nothing afaik.
1562890820
keithcurtis
Forum Champion
API Scripter
Delos A. said: I can't get the 13th Age API working properly. Commands like !edie and !setup do nothing afaik. Do those commands use Sheetworkers? That's the subject of this thread. Just checking, because I'd really like this fixed, and don't want to cloud the waters.
1563297629

Edited 1563297887
Seph
Pro
Sheetworker API failure example API Script : ChatSetAttr Sheet : Pathfinder by Roll20 Command : !setattr --sel --condition_<any>|<1 or 0> OR !setattr --sel --repeating_buff_<$id>_toggle|<1 or 0> Expected Behavior : Actual Behavior : More Info : Only observable if multiple conditions or multiple buffs are toggled on, whether or not they are specified by the command. Example: Helpless, Paralyzed, and a custom buff are marked as active. If the !setattr command is used to toggle the buff to off, the issue still occurs even though the toggle values for Helpless and Paralyzed were not changed by the command. Other changes to the sheet based on the relevant condition/buff happen normally. This issue doesn't cause any error messages to appear in the API. Natha said [ forum post ]: [...] This is weird. But it seems like the sheet worker code on the sheet is not behaving as expected when called "from" the API. The characters added between two conditions are a space, a bullet point and another space. So it seems that the character encoding is not properly done when going through API, and then the sheet workers. [...]
I wonder if this is why the Scum and Villainy sheets started looking odd
1563891785
keithcurtis
Forum Champion
API Scripter
It shouldn't be. This thread is about API not triggering sheetworkers. I would think that would be a CSS issue. Cirolle said: I wonder if this is why the Scum and Villainy sheets started looking odd
1563892320
keithcurtis
Forum Champion
API Scripter
Hi Cassie and Kenton, I know you folks have been short handed because of conventions and such, but is there an update on this fix? Cassie's first post seemed to indicate this was a minor glitch, though I suspect this turned out not to be the case.
1563918594
GiGs
Pro
Sheet Author
The API script function setWithWorkers doesn't appear to work any more, at all. It sets values, just like set, but never causes any sheet workers based on that state to fire. This should be easy to replicate. You just need any stat, and a sheet worker that changes another stat based on the first stat, then try to use setWithWorker to change first stats value. The second stat value won't change. At least it doesnt for me.
1563921640
The Aaron
Forum Champion
API Scripter
It's very likely there is a race condition somewhere.  A very simple repro character and api script does not seem to exhibit the issue: <div> <div> <label for="attr_base">Base Value</label> <input type="text" name="attr_base" value="0" title="Base Value" /> </div> <div> <label for="attr_derived">Derived Value</label> <input type="text" name="attr_derived" value="0" title="Derived Value" /> </div> </div> <div> <button type='roll' value="!repro-setwithworker @{character_id}" name="roll_repro">Test</button> </div> <script type="text/worker"> on('change:base',()=>{ getAttrs(["base"], (attrs)=>{ setAttrs({ derived: (attrs.base * 3) }); }); }); </script> on('ready',()=>{ on('chat:message',(msg)=>{ if('api'===msg.type && /^!repro-setwithworker\b/i.test(msg.content)){ let args = msg.content.split(/\s+/); let c = getObj('character',args[1]); if(c){ let a = findObjs({ type: 'attribute', name: 'base', characterid: c.id })[0]; if(a){ a.setWithWorker({ current: randomInteger(20)-Math.abs(a.get('current')) }); } } } }); }); Intermittent problem are a serious pain to track down. =(
1563924924
The Aaron
Forum Champion
API Scripter
After some further testing, I'm pretty certain this is related to the eventinfo based sheet workers.  Here's a repro sheet and script: <div> <div> <label for="attr_base">Base Value</label> <!-- <input type="text" name="attr_base" value="0" title="Base Value" /> --> <input type="number" name="attr_base" step="1" min="0" max="6" value="0" title="Base Value" /> </div> <div> <label for="attr_derived">Derived Value</label> <input type="text" name="attr_derived" value="0" title="Derived Value" /> </div> <div> <label for="attr_base2">Base Value 2</label> <!-- <input type="text" name="attr_base2" value="0" title="Base Value" /> --> <input type="number" name="attr_base2" step="1" min="0" max="6" value="0" title="Base Value" /> </div> <div> <label for="attr_derived2">Derived Value 2</label> <input type="text" name="attr_derived2" value="0" title="Derived Value 2" /> </div> </div> <div> <button type='roll' value="!repro-setwithworker @{character_id}" name="roll_repro">Test</button> </div> <script type="text/worker"> on('change:base',()=>{ console.log(`%c[One] Change to attribute: %cbase`,'background-color:#ffcccc;','color:#339933;font-weight:bold;'); getAttrs(["base"], (attrs)=>{ setAttrs({ derived: (attrs.base * 3) }); }); }); on("change:base2", function(eventinfo) { console.log(`%c[Two] Change to attribute: %cbase2`,'background-color:#ffcccc;','color:#339933;font-weight:bold;'); console.log(JSON.stringify(eventinfo)); const newValue = parseInt(eventinfo.newValue) || 0, previousValue = parseInt(eventinfo.previousValue) || 0; let update = { derived2: `${previousValue} => ${newValue}` }; setAttrs(update, {silent: true}); }); </script> on('ready',()=>{ on('chat:message',(msg)=>{ if('api'===msg.type && /^!repro-setwithworker\b/i.test(msg.content)){ let args = msg.content.split(/\s+/); let c = getObj('character',args[1]); if(c){ let a = findObjs({ type: 'attribute', name: 'base', characterid: c.id })[0]; if(a){ let newValue = (1+a.get('current'))%7; a.setWithWorker({ current: newValue }); sendChat('Repro',`Set <code>base</code> to <code>${newValue}</code>`); } let a2 = findObjs({ type: 'attribute', name: 'base2', characterid: c.id })[0]; if(a2){ let newValue = (1+a.get('current'))%7; a2.setWithWorker({ current: newValue }); sendChat('Repro',`Set <code>base2</code> to <code>${newValue}</code>`); } } } }); }); eventinfo structures that are issued in the API do not have a triggerName, previousValue, and newValue property.  In the above, that results in the Derived Value 2 field being updated incorrectly.  In many cases, particularly if you do it more than once, it will appear that nothing is being updated (and depending on how the sheet worker uses the value, nothing may be updated). There is an additional strange occurrence when you switch from a change on the character sheet to a change from the API.  In the above, if you manually change the Base Value 2, you can see an event in the local console log for the change.  If you then click the Test button, you'll see another event in the local console log for the API change (missing the newValue property) as well as an event in the API Output Console which is missing all 3 properties from above.  Subsequent API changes will not cause an event in the local console log. One other interesting thing I learn in the foray is that a change to a character sheet does not automatically cause a change to the sheetworkers loaded in the API sandbox, which means you should restart your sandbox if you install a new character sheet.  Probably that isn't a major concern for most people, but if you're developing a character sheet and an API script, you'd need to be aware of that.
1563930566
GiGs
Pro
Sheet Author
I dont think my error was caused by eventinfo based issues, since I wasnt using it. I'll do some more testing. But I wonder if this  One other interesting thing I learn in the foray is that a change to a character sheet does not automatically cause a change to the sheetworkers loaded in the API sandbox, which means you should restart your sandbox if you install a new character sheet.  Probably that isn't a major concern for most people, but if you're developing a character sheet and an API script, you'd need to be aware of that. explains some weirdness I remember seeing when developing a character sheet and an API script in tandem, and finding things not updating properly. 
1564798421
keithcurtis
Forum Champion
API Scripter
Just checking on the status of this. It was reported back in May, examples were requested at the beginning of July, and several folks have posted examples along with some detective work. Just wanted to know if any progress has been made. Thanks.
1565219473
Seconding Keith's request for a status update.
I'm not sure if this is related, but it sounds like it is. Using DnD 5e character sheet with !spelltracking and !longrest the spell slots on the character sheet aren't affected be either command, however the script appears to properly track everything in the chat.  It only looks like the changes in the script aren't populating to the character sheet. I don't know anything about scripting, so I can't really pull the specific commands out for help.  Also, to be fair, everything I'm using has been cobbled together from other people's work, so it's not pretty, but it's been largely functional, so I'm not sure if that's it.
1565557311
keithcurtis
Forum Champion
API Scripter
Could you post the macro text you are using?
1565633042
Cassie
Roll20 Team
Sorry for the long delay. At this time I have no new updates on the topic. As a sheet author & api writer myself, it continues to be on my mind. - Cassie
1565635202
keithcurtis
Forum Champion
API Scripter
Well, rats. The initial post indicated that the cause was known, so I've been hoping for a simple fix. Thanks for the update, Cassie.
1565752566

Edited 1565907138
API Script : Modified Inventory Tracker 5e OGL --&gt;&nbsp; <a href="https://github.com/Gauzin/ROLL20/blob/master/SheetToChat%20-%2019-08-13.js" rel="nofollow">https://github.com/Gauzin/ROLL20/blob/master/SheetToChat%20-%2019-08-13.js</a> &nbsp; &nbsp; (IN PROGRESS, but use !attackShow and click on an item &lt;-- EDITED (had pasted wrong command) Command that fails :&nbsp; !toggleEquipment2 --&gt;&nbsp;&nbsp;hasAttack.setWithWorker({current: this.hasAttack(hasAttack) ? this.HASNOATTACK : this.HASATTACK}); Expected behavior : Upon unchecking and checking with API Script Command, item should automatically get back into the Attacks and Spellcasting section. Actual behavior : The checkboxes check and uncheck themselves, but upon checking the _hasattack box with the sheetworker, a 'new' attack is not created in said section. More info : Toggling the box manually in the sheet produces the desired expected behavior. It's just not working via API. I have another thread with maybe a bit more details. --&gt;&nbsp; <a href="https://app.roll20.net/forum/post/7678155/5e-ogl-help-setwithworker-on-hasattack-attribute-not-adding-the-item-to-attacks-and-spellcasting-section" rel="nofollow">https://app.roll20.net/forum/post/7678155/5e-ogl-help-setwithworker-on-hasattack-attribute-not-adding-the-item-to-attacks-and-spellcasting-section</a> &nbsp; **Thank you Keith for pointing this thread to me ;) Hope this helps!
1567403221

Edited 1567403459
Seph
Pro
Sheetworker API failure example API Script : ChatSetAttr Sheet : Pathfinder by Roll20 Command : !setattr --sel --repeating_buff_&lt;$id&gt;_toggle|1 Expected Behavior :&nbsp; adjusts to Actual Behavior :&nbsp; adjusts to More Info : When the buff toggled on by the API alters the Temp Melee field, the Melee selection in Attack repeating items registers as undefined and so defaults the total attack bonus to +0 . It behaves correctly when manually activated, and it doesn't have this effect when the buff alters the Temp Ranged field.
1567469088

Edited 1567469098
keithcurtis
Forum Champion
API Scripter
I present the Keith Curtis Incredibly Lame Workaround™ to the following particular issue. keithcurtis said: Sheetworker API failure example API Script : ChatSetAttr Sheet : D&amp;D5e by Roll20 Command that fails: !setattr --sel --repeating_damagemod_$0_global_damage_active_flag|1 Expected Behavior : Check referenced Global Damage modifier and activate it Actual Behavior : Checks box, but Global Damage Modifier does not actually activate. You must toggle the box manually for this to happen. More Info : The inverse of this comand:&nbsp;!setattr --sel --repeating_damagemod_$0_global_damage_active_flag|0 works identically: toggles box off, but does not deactivate modifier. ChatSetAttr has setting to "use sheetworkers"; this has been set to ON. This solution may be related to the D&amp;D5e by Roll20&nbsp;sheet. Similar steps do work on Shaped sheet for 5e.
1567524865
keithcurtis said: I present the Keith Curtis Incredibly Lame Workaround™ to the following particular issue. No lameness present there. What a hero. Cheers
1568389010
keithcurtis
Forum Champion
API Scripter
Rotimer said: keithcurtis said: I present the Keith Curtis Incredibly Lame Workaround™ to the following particular issue. No lameness present there. What a hero. Cheers I polished it up a little bit .
As described in this post the APi Script ChatSetAttr no longer works properly due to sheet workers issue. <a href="https://app.roll20.net/forum/post/7770470/set-attr-api-not-updating-parts-of-the-5e-sheet/?pageforid=7771071#post-7771071" rel="nofollow">https://app.roll20.net/forum/post/7770470/set-attr-api-not-updating-parts-of-the-5e-sheet/?pageforid=7771071#post-7771071</a>