5 Replies Latest reply on Jun 24, 2015 8:46 AM by tdanner

    modification of custom properties is not working consistently

    dkeyser

      Hello all,

       

      Another issue I've run into that has me baffled. I'm setting a custom property to indicate that a node has been added via the SDK and it's just not working. This used to work but now it's complaining that the CP doesn't exist when it does. Also in another area I'm allowing users to input nodes via CSV and they can specify a list of CPs and their values to set. This is not complaining at all but again does nothing to the Node CPs. Anyone else having this issue? Any ideas as to why this would happen? Code below:

       

       

       

      #setting value to custom property named ImportedFromScript that is True or False. 0 = False 1 = True.

      $CustomPropBag = @{

      ImportedFromScript = 1;

      }

       

       

      Set-SwisObject $swis -Uri $newNodeUri -Properties $CustomPropBag

       

       

       

       

       

      #Setting Custom Properties from CSV import

      function AddCustomProperties ($customPropertiesTargets, $customPropertiesValues, $NewNodeID)

      {

          $CPNodeID = $NewNodeID.getvalue(3)

       

       

          $CPNodeUri = "swis://WIN-52UF450J3UO./Orion/Orion.Nodes/NodeID=$CPNodeID/CustomProperties"

       

       

          $CPTargetCount = $customPropertiesTargets.Count

          $CPIndex = 0

       

       

      while ($CPTargetCount -gt $CPIndex)

      {

          $Name = $customPropertiesTargets[$CPIndex].tostring()

          $Value = $customPropertiesValues[$CPIndex].ToString()

          $CustomPropBagCP = @{

          $Name = "$Value"

          }

          Set-SwisObject $swis -Uri $CPNodeUri -Properties $CustomPropBagCP

          $CPindex = $CPindex + 1

      }

       

       

       

       

      }

        • Re: modification of custom properties is not working consistently
          Jan Pelousek

          Hello, not sure which part of code doesn't work, but I can see you're using $CPNodeUri - it's format is fine... For setting of ImportedFromScript CP you're using the $newNodeUri, which I expect you're getting directly from New-SwisObject command and it's not correct. For updating you always need to have the uri in format(per your case)

          ($newNodeUri + '/CustomProperties')

          as you're using in the following code.

          I confess updating of the CPs via just Node URI worked before 2015, but it was more accidentaly because the CPs were physically located in the same table, which is no more true (Nodes are now view from more tables).

           

          If you still have problems, please share the error messages you're getting and actual uri values and property bag content.

           

          Regards,

          H.