Search code examples
smartsheet-apismartsheet-c#-sdk-v2

Need to change Access Control of Published Items though api


In Smartsheet I have downloaded Published Items list from user management. Using this list I need to change the Access control (Public/Organization) value through api. Please help. Thanks


Solution

  • Depending on the type of object you're updating (Sheet, Report, or Dashboard), the operations you'll use are as follows:

    I've included some code examples below (taken nearly verbatim from those you'll find in the docs I've linked to above.)

    One additional note: You'll notice that the values written to the Published Items list that you manually export from Smartsheet differ from the values used by the API. For example, the Access Control column of exported data contains values like Organization and Public -- where as the corresponding values used by the API are ORG and ALL.

    Example #1: SHEET --> Set ReadOnlyFullAccessibleBy to ALL, ReadWriteAccessibleBy to ORG

    SheetPublish sheetPublish = new SheetPublish();
    
    sheetPublish.ReadOnlyLiteEnabled = false;
    sheetPublish.ReadOnlyFullEnabled = true;
    sheetPublish.ReadOnlyFullAccessibleBy = "ALL";
    sheetPublish.ReadWriteEnabled = true;
    sheetPublish.ReadWriteAccessibleBy = "ORG";
    sheetPublish.IcalEnabled = false;
    
    smartsheet.SheetResources.UpdatePublishStatus(
      4583614634583940,       // sheetId
      sheetPublish
    );
    

    Example #2: Report --> Set ReadOnlyFullAccessibleBy to ORG

    ReportPublish reportPublish = new ReportPublish();
    
    reportPublish.ReadOnlyFullEnabled = true;
    reportPublish.ReadOnlyFullAccessibleBy = "ORG";
    
    smartsheet.ReportResources.UpdatePublishStatus(
      1653087851556740,    // reportId
      reportPublish
    );
    

    Example #3: Dashboard (Sight) --> Set ReadOnlyFullAccessibleBy to ALL

    SightPublish publish = new SightPublish();
    
    publish.ReadOnlyFullEnabled = true;
    publish.ReadOnlyFullAccessibleBy = "ALL";
    
    smartsheet.SightResources.SetPublishStatus(
      5363568917931908,    // sightId
      publish
    );