The Spotfire Community is moving to TIBCOmmunity and this forum location has closed. During the transition, you can still search the old forums but posting has been disabled. We encourage you to pick up the discussion at the new Spotfire community on TIBCOmmunity.
December 2012 - Posts - Tip of the Week

Tip of the Week

December 2012 - Posts

  • Passing Marked Records to External Web Pages - Part II

    Last week we discussed how to create a Mashup to send information from the Spotfire Web Player to an external web site.  As a follow up to this, you may have a requirement to do this from Spotfire Professional only (not from the Spotfire Web Player). In this scenario, this easiest approach is to reuse the Collaboration Panel along with a Script Control. The Script will collect the necessary information from the marked records and then will pass it to a website that is displayed inside the Collaboration Panel.


     
    The first thing the Script needs to do is return the currently marked records:

    rowIndexSet=Document.ActiveMarkingSelectionReference.GetSelection(Document.Data.Tables["Car Data"]).AsIndexSet()

    Next, the Script will check if the marked records Index Set that was returned is empty or not. If it is not empty it will retrieve the value from the Make and Model columns for the Marked Records. (In this Script we just retrieve the first row from the marking, but this can be updated to retrieve all rows if multiple ones are marked)

    if rowIndexSet.IsEmpty !='false':
        make = Document.Data.Tables["Car Data"].Columns["Make"].RowValues.GetFormattedValue(rowIndexSet.First)
        model = Document.Data.Tables["Car Data"].Columns["Model"].RowValues.GetFormattedValue(rowIndexSet.First)

    Then we build the URL to pass into the Collaboration Panel. That API requires a Uri object to be passed in for the URL.

    urlString = "http://www.cars.com/go/search/newBuyIndex.jsp?stkTyp=N&tracktype=newcc&mkId=20006&AmbMkId=20006&AmbMkNm=" + make + "&make=" + make + "&AmbMdNm=” + model +  “&model=” + model
    link = Uri(urlString)

    Finally we get a hold of the Collaboration Panel from the Panels collection. We make sure it is visible and then set the Url property to the Uri we just created.

    for panel in Document.ActivePageReference.Panels:
      if panel.TypeId == PanelTypeIdentifiers.CollaborationPanel:
          if panel.Visible == False:
             panel.Visible = True
          panel.Url = link


    The complete Script is shown below:

    from Spotfire.Dxp.Application import PanelTypeIdentifiers
    from System import Uri

    rowIndexSet=Document.ActiveMarkingSelectionReference.GetSelection(Document.Data.Tables["Car Data"]).AsIndexSet()

    if rowIndexSet.IsEmpty !='false':
        make = Document.Data.Tables["Car Data"].Columns["Make"].RowValues.GetFormattedValue(rowIndexSet.First)
        model = Document.Data.Tables["Car Data"].Columns["Model"].RowValues.GetFormattedValue(rowIndexSet.First)
        urlString = "http://www.cars.com/go/search/newBuyIndex.jsp?stkTyp=N&tracktype=newcc&mkId=20006&AmbMkId=20006&AmbMkNm=" + make + "&make=" + make + "&AmbMdNm=” + model +  “&model=” + model
        link = Uri(urlString)

    for panel in Document.ActivePageReference.Panels:
      if panel.TypeId == PanelTypeIdentifiers.CollaborationPanel:
          if panel.Visible == False:
             panel.Visible = True
          panel.Url = link

Syndication

Other Spotfire Blogs

©Copyright 2000-2011 TIBCO Software Inc | Privacy Policy | Terms of Use I Blog I Contact Us I Content Center