Advertisement Create a free account

getAttrs not defined

Any idea why an API script which allows the command setAttrs would spit back the error that "getAttrs is undefined"? Below is the snippet that fails:                                 var rowID = generateRowID(); var attributes = {}; attributes['repeating_inventory_' + rowID + '_itemname'] = new_item; attributes['repeating_inventory_' + rowID + '_itemweight'] = value; attributes['repeating_inventory_' + rowID + '_itemcount'] = 1; attributes['repeating_inventory_' + rowID + '_itemcontent'] = 'description';                 var bid = char.get('id'); setAttrs(bid, attributes); getAttrs(['inventory'], (values)=>{log(values)});

Edited 1581479782
Sheet Author
getAttrs is a sheet worker function, not an API function. To grab attributes from a character sheet in an API script you need to use the functions on this page:&nbsp; <a href="" rel="nofollow"></a> Even if it was a sheet worker function, getAttrs['inventory'] wouldnt work, because there is no single inventory attribute. To grab all the attributes from a repeating section, you need to use getSectionIDs. Again that's a asheet worker function, not an API function, and only works as part of character sheet code. Also, there are two different functions called setAttrs. The one for sheet workers has different syntax for the one in the API. They are not the same function.