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.

Invoking Orion.Views - AddViewToGroup

Hello Orion SDK Community,

I'm Invoking the following verb as an attempt to join two pages together into a viewgroup with a tabbed interface (the same as if you customized a view, enabled the tabbed interface option, and added a new tab)

I'm not sure why this isn't working, as I believe I am setting the properties correctly.

As a test, I create two separate views, and then use SWQL studio to invoke the AddViewToGroup verb setting the parameters as follows:

viewID: (viewID of the first resource)

targetViewID: (viewID of the second resource)

viewIcon: Overview.png

viewCondition: (not a required property, I've tried leaving this empty or setting to true)

The result is that when this is submitted, and you browse to the targetViewID, two pages are not seen, only one.

Customizing the page reveals the tabbed interface is enabled and the pages are both seen grouped together in the customize view, yet they only one page appears.

Reviewing the database, values all seem correct (ViewGroupID is the same, ViewGroupPostions are 1 and 2) yet the page does not display the tabbed interface.

Is there something I am missing here? Perhaps I'm setting values incorrectly?

Any help is greatly appreciated.

Thank you,

=swql

  • I wrote a script not long ago that was trying to bulk deploy dashboards for a bunch of locations, and ultimately I had no success with the add to group verb.  What I ended up doing was just creating all my tabs using the clone view command against a template and then using update operations to manually define all the viewgroupids as I went and paired the views up, then the script applied view limitations to get it filtered how I wanted it.  It was clunky and took a lot of babysitting but in the end I was able to get the task done and it did take effect within the web console as soon as I made my updates.  You mentioned that the viewgroupip and viewgrouppositions were correct, only other thing that I can remember that I had to set as part of my scripts was the viewgroupnames.

    I'd post the script but it is very much a work in progress and I'd be ashamed to have anyone try to use it as is.

  • Thanks for the reply @mesverrum,

    It's good to hear that you were able to successfully get the pages joined together, that was going to be my next step - altering the IDs/Groupnames/Positions manually.

    At least knowing you were able to do it gives me some hope - I'm going to try to do the update using Update-SwisObject? I think it is, if that doesn't work I'll go to SQL.

    I may PM you regarding that script, I'd be willing to trade my WIP script that you might find very useful as well - but the info you have given me will likely be enough of a clue to get this working for me.

    Thanks!

  • Problem may be in "viewCondition" value - value should be NULL. Blank value for viewCondition will hide the view. However I'm not sure if it's possible to pass NULL value in SWQL Studio.

    You can check DB table [ViewConditions], if no view conditions are applied there should be no record for given view.

    You can use PowerShell or Python to invoke the verb and pass NULL value to viewCondition.

    Passing NULL value in Python can be done using None keyword:

    swis = SwisClient(npm_server, username, password)

    requests = swis.invoke('Orion.Views', 'AddViewToGroup', 16, 15, 'Overview.png', None);

  • Thank you tomas.vrabel​,

    So if I understand correctly, an entry in the ViewConditions table means that the view will be hidden? I will attempt to use this verb using powershell and set with a null value and let you know the result.

    Thank you again,
    =swql



  • Yes, in our case entry in ViewConditions table for our merged view means that view is hidden as we provided invalid values for view condition (empty string, "true").

    However for other views there can be correct/valid view condition that control view visibility and does not hide view always.

    To be more precise - Orion allows hiding views based on complex evaluation and some views use this functionality (e.g. show asset inventory view if asset inventory data are available for node).

    Evaluation for given view is done based on value in ViewConditions table. If value in ViewConditions is not recognized, view is hidden. Both empty string and "true" that were provided in SWQL studio are not recognized so view was hidden.

  • Hello tomas.vrabel​,

    Just as you said, after removing the entry/row I found in the table you mentioned and reloaded the page, the tabbed interface appeared. I haven't yet invoked the verb via powershell, but I'm confident that when I do set the optional parameter to null, it should work fine.

    Thank you again!

  • Hi  

    I used the same way to create my views (duplication of a template), but i can't found the way to apply view limitation (the command Orion.Limitation seems to be for Account Limitation)

    How did you do that ?

    thanks

    [edit : got it >> set-swisobject]

  • I also need to create views with sub views. Sadly I need to add/remove depending on what is monitored. For me it worked not to use the Swis verb but use the object update function. 

    I created a ViewGroup ID by using the SWIS Verb "AddViewToGroup" on the Main View (Both source and target are the same ID):

    $ret = Invoke-SwisVerb $swis Orion.Views AddViewToGroup @( $MainViewID, $MainViewID, "Overview.png") 
     

    and added it together with the group name (same as view name), the order (n+1) and the icon  to the "sub view" and it was there (Powershell):

    $MainViewID = 4711 # ID of the master view
    $ViewID = 5432 # ID of the View to add to the master view
    $MainViewID,$ViewGroup,$ViewGroupName = `
      Get-SwisData  $swis "Select ViewID,ViewGroup,ViewGroupName from Orion.Views where ViewID = $($MainViewID)"
    if ($MainViewID) {
     $ViewGroupPosition = `
       Get-SwisData  $swis "SELECT  MAX(ViewGroupPosition) as maxi FROM Orion.Views where viewgroup=$($ViewGroup)"
     $ViewGroupPosition++
     if (! (Get-SwisData $swis "Select ViewGroupPosition from Orion.Views where where ViewID=$($ViewID)") ) {
       $Uri=Get-SwisData $swis "Select URI from Orion.Views where where ViewID=$($ViewID)"
       $ret = Set-SwisObject $swis -Uri $Uri -properties @{ ViewGroup = $ViewGroup ;
                                                                         ViewGroupName = $ViewGroupName ;
                                                                         ViewGroupPosition = $ViewGroupPosition;
                                                                         viewIcon = "Nexus-VPC.png" }
      if ($ret.InnerText -ne "true") {
         Write-Host "Error: Factory view not added to main view!"
       }
     } 
    }

    Maybe that helps. Especially the "order" thing can be more sophisticated (how to insert a view between to others for example).