Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Strange behaviour with subsequent createGenericObject calls

Hi,

I'm trying to get information about my app's dimensions and measures in v1.0.0 of Sense.

To get the dimensions, I use this API call:

app.createGenericObject({

                        qDimensionListDef: {

                            qType: "dimension",

                            qData: {

                                title: "/title",

                                tags: "/tags",

                                description: "/description"

                            }

                        }

                    }, function(reply) {

                         // do stuff                       

                    });

And to get the measures, I use this API call:

app.createGenericObject({

                        qMeasureListDef: {

                            qType: "measure",

                            qData: {

                                title: "/title",

                                tags: "/tags",

                                description: "/description"

                            }

                        }

                    }, function(reply) {

     // do stuff

});

Both of these calls are in separate functions in an angular service, which I inject into my controller.  They use promises, and I invoke them as a single call, it all works fine.

I have a third function in my service, getData, which calls them both, using the following code (where 'q' is injected as type $q):

getData : function() {

                    var d = q.defer(),

                        promises = [];

                    promises[0] = this.getDimensions();

                    promises[1] = this.getMeasures();

                    q.all(promises).then(function(reply) {

                        d.resolve(reply);

                    });

                    return d.promise;

                }

This is then called from my controller using the getData.then(function(reply) { }) type syntax.  The service javascript file is attached to this question.

The problem is that when both are called this way, the second call (to measures) seems to once again return dimension information, whereas when it is called by itself, works as expected.

I don't know why it isn't working as I expect.  Am I missing something crucial?

Thanks,

Shane.

1 Solution

Accepted Solutions
ErikWetterberg

HI Shane,

If you are doing this from an extension there is an easier way, which might work better.

You can define both lists in initialProperties. Something like this:

initialProperties : {

          qMeasureListDef: {

               qType: "measure",

               qData: {

                       title: "/title",

                       tags: "/tags",

                      description: "/description"

                       }

            },

          qDimensionListDef: {

               qType: "dimension",

               qData: {

                        title: "/title",

                       tags: "/tags",

                      description: "/description"

               }

            }

        }

Your layout will then contain both a qMeasureList and a qDimensionList. This method is used in the Toolbar extension example (but with fields and bookmarks).

View solution in original post

2 Replies
ErikWetterberg

HI Shane,

If you are doing this from an extension there is an easier way, which might work better.

You can define both lists in initialProperties. Something like this:

initialProperties : {

          qMeasureListDef: {

               qType: "measure",

               qData: {

                       title: "/title",

                       tags: "/tags",

                      description: "/description"

                       }

            },

          qDimensionListDef: {

               qType: "dimension",

               qData: {

                        title: "/title",

                       tags: "/tags",

                      description: "/description"

               }

            }

        }

Your layout will then contain both a qMeasureList and a qDimensionList. This method is used in the Toolbar extension example (but with fields and bookmarks).

Not applicable
Author

Hi Erik,

that worked great, and I've got the data I need.

However, the curious part of me is still wondering why the 2 calls before did not work as I expected.

Thanks,

Shane.