Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 1 addition & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,7 @@ To be able to use this module you need :
- Once the module is imported, you need to store it (it will store encrypted using windows Data protection API)
> Set-SmartSheetAPIToken [your Token]

To use the Module :
> get-smartsheet
Will show you all the smartsheets you are able to read.

> $MySS = get-smartsheet MySmartsheet*
This will load (only if there is a single SmartSheet corresponding to the name) the smartsheet to the variable $MySS

> $MySS = get-smartsheet -ID 123412341234
This will load the EXACT smartsheet to the variable.

> $MySS.table
This will show you your smartsheet

If you have hiearchy starting at line 3
> $MySS.table[2].__Childnode
This will show the Child nodes

> $MySS.table[5].ColumnName = "New Value"
> $MySS.table[5].update()
Those 2 commands will update the smartsheet at line 6, the column called "ColumnName" and set the cell to the value "New Value"
Please check the wiki for instructions


Regards to all
Expand Down
Binary file modified SmartSheet/SmartSheet.psd1
Binary file not shown.
19 changes: 11 additions & 8 deletions SmartSheet/SmartSheet.psm1
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# SmartSheet Version 2.0
# Developped by Thomas Farray .:|:. Cisco .:|:.
# Updated to work with API V2

if (!(get-module ModulesUpdater)) { import-module ModulesUpdater }
Expand Down Expand Up @@ -166,13 +164,13 @@ function ConvertTo-SmartSheetRowObject {
param($JasonRow,$SS)
process {
# write-verbose $JasonRow.count
if ($JasonRow | ? { $_.parentId }) { $Hiearchy = $true } else { $Hiearchy = $false }
foreach ($JSR in @($JasonRow)) {
# First we put all data and we create the object
# $Properties = $ss.Colname2ID.Clone()
$Properties = @{}
if ($Hiearchy) { $ValuesToShow = @("H") ;$Properties = @{"H" = $null} } else { $ValuesToShow = @() ; $Properties = @{}}
$Properties.add("__id",$JSR.id)
$Properties.add("__smartsheet",$SS)
$ValuesToShow = @()
$JSR.cells | select columnId,value | ? { $_.columnId -in $SS.ID2Colname.Keys } | % {
$ColName = $SS.ID2Colname.($_.columnId)
$Properties.add($ColName,$_.value)
Expand All @@ -192,21 +190,26 @@ function ConvertTo-SmartSheetRowObject {
# write-verbose "Addin Data To parent & child"
$Parent = $ss.Table_ID2PSo.($JSR.parentId)
add-member -inputobject $NewRow noteproperty -name "__ParentNode" -value @($Parent)

#Managing Tree
if (!$Parent.__Childnode) { $NewRow.H = "-|" } else { $NewRow.H = " |" }
if ($Parent.H) { $NewRow.H = ($Parent.H -replace "-"," ") + $NewRow.H }

if ($Parent.__Childnode) {
$Parent.__Childnode += $NewRow
} else {
add-member -inputobject $Parent noteproperty -name "__Childnode" -value @($NewRow)
}
} else {
$SS.table += @($NewRow)
}

}
$SS.table += @($NewRow)

# We now add to the Smartsheet the new row and we add All methods
$SS.Table_ID2PSo.add($JSR.id,$NewRow)
Add-Member -InputObject $NewRow -MemberType ScriptMethod -Name 'Update' -Value $SSUpdateRowBlock #-PassThru
Add-Member -InputObject $NewRow -MemberType ScriptMethod -Name 'AddChild' -Value $SSAddNewChild #-PassThru
Add-Member -InputObject $NewRow -MemberType ScriptMethod -Name 'AddRow' -Value $SSAddNewRow #-PassThru
Add-Member -InputObject $NewRow -MemberType ScriptMethod -Name 'Delete' -Value $SSRemoveRow #-PassThru

}
}
}
Expand Down