7 Replies Latest reply on Dec 8, 2015 9:30 AM by bsmith RSS
    bsmith Apprentice

    Using a Mashup Parameter as the Query Filter?

    How can I include a parameter passed into the mashup as the input to a query?

     

    For example:

    1. MashupA has a mashup parameter named “PassedSiteId”

        2. The mashup uses the query service “QueryImplementingThingsWithData”.  (Note: SiteId is one of the properties of the instantiated Things and I want to filter on that).

     

    So I want the query in the “QueryImplementingThingsWithData” to be:   SiteId = PassedSiteId

     

    I only see how to place hard coded literals in the query target.

     

    Any pointers to documentation or examples?

     

    Thanks,

      • Re: Using a Mashup Parameter as the Query Filter?
        qn Communicator

        You can create a new service with an input "SiteIdParam". This service executes the "QueryImplementingThingsWithData" with the query which contains "SiteId = SiteIdParam".


        Then, in the mashup, you can bind the mashup parameter "PassedSiteId" to the input parameter "SiteIdParam" of this new service.

          • Re: Using a Mashup Parameter as the Query Filter?
            bsmith Apprentice

            This works.  Thanks for the input.

            • Re: Using a Mashup Parameter as the Query Filter?
              bsmith Apprentice

              Once the new service is created it only shows up as dynamic and I can't seem to get the List (all data) and Grid (selected data) mashup to work as it did formally with QueryImplementingThingsWithData.

               

              I am missing some understanding on how to use the Dynamic service.

               

              Can you give me a pointer to documentation on how to implement?

               

              Thanks,

                • Re: Using a Mashup Parameter as the Query Filter?
                  qn Communicator

                  I'd like to know what is the ouput of your new service. You would need to create a new DataShape which contains only the properties that you need for the List and the Grid. In this case, the output of the new sevice will be an InfoTable with the new DataShape created.

                   

                  If you want to use the new service without Dynamic option, you could create a new Thing (for example, MyThingController) which implents the Thing Template GenericThing. Then, the new service can be created inside of this Thing. In this case, this service must have an input ThingName which is binded with the Thing / Thing Template used for the List and the Grid.

                   

                  To this day, I have not found (yet) another documentation on the Dynamic service which gives more details on how to implement:

                  http://support.ptc.com/cs/help/thingworx_hc/thingworx_6.5_hc/index.jspx?id=DataServicesandScalableSolutions&action=show

                    • Re: Using a Mashup Parameter as the Query Filter?
                      bsmith Apprentice

                       

                      QD,

                       

                      Thanks for the reply.

                       

                      I was able to successfully create the service, defined the DataShape that contains the properties needed and with the output being an InfoTable.  That all works properly.

                       

                      I will look into your suggestion on how to use the new service without Dynamic option and let you know the outcome.  The problem comes when you need to dynamically filter on something like QueryImplementingThingsWithData at runtime to initially seed a List.  I.e. I don’t want to show all the Things Implemented but also don’t want to hard code the restricting query parameter.

                        I too have not found (yet) another documentation on the Dynamic service which give more details other than the one you listed .

                       

                      Thanks,

                       

                        • Re: Using a Mashup Parameter as the Query Filter?
                          qn Communicator

                          Hi Beck,

                           

                          Glad to know that your implementation works.

                           

                          I had the problem with de Dynamic filter too. I don't know what filter of QueryImplementingThingsWithData would you need. In my case, I just need to be able to select one of MyThings dynamically. My solution is:

                          - In the ThingShape GlobalSessionProperties (Show System Objects to be able to see), a new property is created, which is a ThingName base type and which implements the ThingShape, or the ThingTemplate, of all of MyThings

                          - Add this ThingShape to the UserManagementSubsystem

                          - After that, in every mashup, I have this Session property. I can bind it to the input ThingName of my service created in the previous post


                          Here is an answer of Pai Chung in Made a template, added a service to it. Service is 'Dynamic' - why?:

                          I'm not sure where you are seeing Dynamic, but any Services a user adds to a ThingTemplate will only execute at the Instance (Thing) level.

                          So it maybe referring to that.

                          Within the Mashup building environment we use the Dynamic check box to be able to dynamically at runtime specify an instance based upon a given template and execute the services.

                          Quang-Dung