This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

Assign View Type through SDK

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.

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

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

    pastedImage_0.png

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

  • 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