smartsheet api - Get sheets belonging to a specific group -


how tell if sheet belongs group?

for example, have group called rpr , when create sheets share them other users in our organization applying group sheet.

// sheets modified within last day     smartsheetlist = smartsheet         .sheetresources         .listsheets(new sheetinclusion[] { sheetinclusion.owner_info }, new paginationparameters(true, null, null))         .data         .where(d => d.modifiedat.value.date >= datetime.now.adddays(-1).date)         .tolist();  // organization sheets var orgusersheets = smartsheet.userresources.sheetresources.listsheets(true).data.tolist();  // specific group var group = smartsheet.groupresources.listgroups(null).data.where(grp => grp.id == some-id-here).first(); 

with code above can see if sheet belongs organization can't tell if sheet belongs group. appreciated.

you need 1 more api request each sheet retrieve list of shares on sheet. keep in mind, sheets can shared directly on sheet or via workspace.

to sheets shared specific group directly or via workspace, can use code below (relying on linq sample).

smartsheetclient cl = new smartsheetbuilder()     .setaccesstoken(access_token)     .build();  var includeall = new paginationparameters(true, null, null); console.writeline("looking group " + sought_group_name); var groups = cl.groupresources.listgroups(includeall); var soughtgroup = groups.data.single((group) => group.name == sought_group_name); console.writeline("found group id {0} group {1}.", soughtgroup != null ? soughtgroup.id.tostring() : "null", sought_group_name); if (soughtgroup == null)     throw new argumentexception("group not found");  var sheets = cl.sheetresources.listsheets(null, includeall); console.writeline("querying through {0} sheets...", sheets.data.count); var sheetssharedwithgroup = sheet in sheets.data                             share in cl.sheetresources.shareresources.listshares(sheet.id.value, includeall, sharescope.workspace).data                             share.groupid == soughtgroup.id                             select new { sheet = sheet, share = share };  var found = sheetssharedwithgroup.tolist(); console.writeline("found {0} sheets shared group {1}.", found.count, sought_group_name); found.foreach(foundsheet => console.writeline("sheet {0} shared {1} ({2})", foundsheet.sheet.name, foundsheet.share.name, foundsheet.share.type)); 

note: submitted a pull request add support specific listshares overload returns workspace shares too. available in rest api wasn't yet in c# sdk.

note: above code not take account smartsheet sights yet. should possible using corresponding rest api sights (i.e. list sights, list sight shares, don't think that's in c# sdk yet.


Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -