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

[Help] Trouble getting repeating attributes with findObjs()

1514910582
Missingquery
Pro
Sheet Author
API Scripter
I have an attribute, named fIDA, with a value set to the row ID of the firstmost repeating row (achieved with sheet worker scripts, and that seems to be working fine). However, I always get undefined whenever I attempt to use this row ID when getting another attribute in the row with findObjs(): let fIDA = findObjs({ characterid: attacker.id, name: "fid"})[0]; log(fIDA) let UsesA = findObjs({ characterid: attacker.id, name: "repeating_weapons_"+fIDA.get("current")+"_Uses"})[0]; log(UsesA) //attacker is a character object that I've used for several other attributes and confirmed is valid Which returns: {"name":"fid","current":"-l05pfz3iubzuqslklnz","max":"","_id":"-L1oSDbBeP_8zPEHyndP","_type":"attribute","_characterid":"-L-wW5DNHeTq46wpudNZ"} //This is fine undefined I've also tried using "repeating_weapons_$0_Uses" as suggested in another post, but that doesn't seem to be working either.
1514911762
The Aaron
Pro
API Scripter
Try adding: let fIDA = findObjs({ characterid: attacker.id, name: "fid"})[0]; log(fIDA) let UsesA = findObjs({ characterid: attacker.id, name: "repeating_weapons_"+fIDA.get("current")+"_Uses" } , { caseInsensitive: true } )[0]; log(UsesA) //attacker is a character object that I've used for several other attributes and confirmed is valid
1514911997
Missingquery
Pro
Sheet Author
API Scripter
Yep, that did the trick! Thanks!
1514912061
The Aaron
Pro
API Scripter
If that doesn't work, try something like this to see what is actually there for that fIDA: let fIDA = findObjs({ characterid: attacker.id, name: "fid"})[0]; log(fIDA) let r = new RegExp(`repeating_.*${fIDA}_.*`,'i'); // regex to match repeating attributes with that id _.chain(findObjs({         type: 'attribute',         characterid: attacker.id     })     .filter((o)=>r.test(o.get('name')))     .each((o)=>log(`FOUND: ${o.get('name')}`))     ; //attacker is a character object that I've used for several other attributes and confirmed is valid
1514912069
The Aaron
Pro
API Scripter
ah, great!