diff --git a/README.md b/README.md index a2d329e..afd8c0d 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/SmartSheet/SmartSheet.psd1 b/SmartSheet/SmartSheet.psd1 index 16ad76c..93e7e97 100644 Binary files a/SmartSheet/SmartSheet.psd1 and b/SmartSheet/SmartSheet.psd1 differ diff --git a/SmartSheet/SmartSheet.psm1 b/SmartSheet/SmartSheet.psm1 index 64ac2ff..1666b9f 100644 --- a/SmartSheet/SmartSheet.psm1 +++ b/SmartSheet/SmartSheet.psm1 @@ -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 } @@ -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) @@ -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 + } } }