4 Replies Latest reply on Mar 14, 2017 7:37 AM by ebender

    Assign View Type through SDK

    ebender

      Is it possible to assign a View Type to a node through the SDK?

       

      I have a script that will add the node for monitoring, assign UnDP, set custom properties, assign a new caption, set node poll interval, etc., but I can't seem to find a way to assign a View Type to a node through the SDK.

        • Re: Assign View Type through SDK
          tdanner

          I'm not sure exactly what you are looking for. How would you do the same task through the UI?

            • Re: Assign View Type through SDK
              ebender

              On the Edit Node Properties page, there's a drop-down menu to assign View Type:

               

              From there, I can pick a specific view for that particular node.

                • Re: Assign View Type through SDK
                  tdanner

                  This is in the Orion.NodeSettings entity with a SettingName of "ViewId" and a SettingValue equal to the desired ViewID. A View Type of "(default)" corresponds to no setting. You can look up the ViewID values by querying Orion.Views.

                   

                  Newly-created nodes will have no value in Orion.NodeSettings, so you can just create an instance to set the ViewID. In PowerShell, that would look like this:

                   

                  $swis = Connect-Swis ...

                  $nodeid = 11

                  $viewid = 57

                  New-SwisObject $swis Orion.NodeSettings @{NodeID=$nodeid;SettingName='ViewId';SettingValue=$viewid}

                   

                  If you want to set/change the ViewId for an existing node that might already have one set, you need to remove any previous setting first. You can do that like this:

                   

                  Get-SwisData $swis "SELECT Uri FROM Orion.NodeSettings WHERE NodeID=$nodeid AND SettingName='ViewId'" | Remove-SwisObject $swis