From 8c491eddaea218431603ca4fe0ff1262d6e0d6cb Mon Sep 17 00:00:00 2001 From: tfarray Date: Wed, 14 Dec 2016 15:43:01 +0100 Subject: [PATCH 1/2] updates updates --- SmartSheet/SmartSheet.psd1 | Bin 2022 -> 1974 bytes SmartSheet/SmartSheet.psm1 | 19 +++++++++++-------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/SmartSheet/SmartSheet.psd1 b/SmartSheet/SmartSheet.psd1 index 16ad76c3cd553e0afff61cdb5dd7146723e62cea..93e7e971821b382843152d1964ff433d7f6a1835 100644 GIT binary patch delta 36 pcmaFHzm0!G7^AowLlHwN5GpXFG2{c;3Ji%1ISe_Q=Q4V-0RXMR2)h6P delta 84 zcmdnS|BQb_7^AxeLo$OVg93vQg8_pfgBg(J%#g`Y3>3|0&;#-u8FGM7fuRT}n$D2H ZPy&<#@lt_wDv&M%k|_*&n{ydG*#M(65A6T| 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 + } } } From 7ec5b028ba7b3a4932a433e53faaad14ae77dfcd Mon Sep 17 00:00:00 2001 From: tfarray Date: Thu, 15 Dec 2016 11:56:11 +0100 Subject: [PATCH 2/2] Update README.md --- README.md | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) 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