Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
chriscammers
Partner - Specialist
Partner - Specialist

Tags and custom properties in load script

We are moving from QlikView to Qlik Sense and a common practice in Qlikview was to define weather a document was in the development or production environment. Then the load script would adjust data connection paths to pull from the production or development data as needed. I want to implement this in Sense but there does not seem to be any way to define the environment without physically changing the code before moving to production.

I was thinking that I could avoid code changes prior to deployment by manipulating either the Tags or Custom properties of the app.

Are the App Tags or Custom Properties available to the load script?

How do I read them into a variable in Sense Server? Do they exist at all in Sense Desktop??

Thanks

Chris

5 Replies
Not applicable

Hi Chris, We seem to be in a same predicament. Were you able to find a solution to this scenario? We are faced with a similar requirement (programatically adjust  data connection in load script based on user and set environment variables) or have an ability to pass these via URL or session. I am not finding any information on this..

Were you able to come up with something that works or consume custom property values in load script?

Your advice is much appreciated,

-Stan

chriscammers
Partner - Specialist
Partner - Specialist
Author

Greetings Community,

I wanted to bump this discussion back to the top because we made a discovery a few days ago and I am finally getting to test out the theory.

With the release of QlikSense 3.0 I was overjoyed to discover that the Qlik Rest connector was now included with QlikSense. In Addition, connectors for getting information from the repository were also included in the release. the connectors include

qrs_app

qrs_appobject

qrs_event

qrs_licenseSummary

qrs_loginAccess

qrs_task

qrs_user

qrs_userAccess

This was exactly the solution I was looking for, these connectors allow me to query the repository and get information about my app so I can switch between Dev and Production without having to alter my code.

I am working on some testing with the qrs_app connector and I found that I can use the DocumentPath function to get the guid for the app when it is running and then condition the rest query to return information about that document.

Unfortunately, I am finding that the Custom Properties and Tags are not populating in the queries.

At first I thought I was having a caching issue but it does not appear that the values are populating.

Does anybody have any insight into the workings of the qrs connectors?

Thanks

Chris

EmmaC
Partner - Creator
Partner - Creator

Hi! I am exactly looking for the same! To retrieve the tags ! did you find a solution?

regards,

Emma

rohitk1609
Master
Master

Hi Emma,

What you can do in QlikView you can do in Qlik Sense for path. How we do in Qlik View, we create a text file and put connection string there and then call the connection string with the help of include function in our application

http://help.qlik.com/en-US/qlikview/12.1/Subsystems/Client/Content/Scripting/SystemVariables/Include....

When you move your development application to production , you just need to update the connection string in the same text file, table names will be same just database environment will be changed.

The same thing you can do in Qlik Sense. Tags and Custom property will not help you in this. these two things are part of QMC and we use Include function in Load script. Same application without modification will work. Nothing to do extra.

I hope I have answered your question.

chriscammers
Partner - Specialist
Partner - Specialist
Author

Emma,

As of my last reply we did use custom attributes and the repository rest connectors as I listed above to pull custom attributes from the QMC Repository. We did implement the solution and then Qlik Deprecated the connectors and replaced them with different ones.

Here is what I have running at one of my clients I use is as an include file for all my apps at the end you willhave a variable named vEnvironmentName that is either Development or Production.

//Configuration section

//set vEnvironmentPropertyName to match the name of the QMC custom property used to define the environment

Let vEnvironmentPropertyName = 'ApplicationEnvironment';

//initialize making sure I don't reuse the value from the last run.

Let vEnvironmentName = null();

Let vEnvironmentCount = 0;

//Find the guid for this application.

Let vMe = documentname();

//Query the application data from the qmc

LIB CONNECT TO 'qrs_app';

RestConnectorMasterTable:

SQL SELECT

    "id" AS "id_u4",

    "createdDate" AS "createdDate_u0",

    "modifiedDate" AS "modifiedDate_u0",

    "modifiedByUserName" AS "modifiedByUserName_u0",

    "name" AS "name_u3",

    "appId",

    "publishTime",

    "published",

    "description",

    "fileSize",

    "lastReloadTime",

    "thumbnail",

    "savedInProductVersion",

    "migrationHash",

    "dynamicColor",

    "availabilityStatus",

    "privileges" AS "privileges_u3",

    "schemaPath" AS "schemaPath_u0",

    "stream",

    "__KEY_root",

    (SELECT

        "id" AS "id_u0",

        "createdDate",

        "modifiedDate",

        "modifiedByUserName",

        "value",

        "schemaPath",

        "__KEY_customProperties",

        "__FK_customProperties",

        (SELECT

            "id",

            "name",

            "valueType",

            "privileges",

            "__KEY_definition",

            "__FK_definition",

            (SELECT

                "@Value",

                "__FK_choiceValues"

            FROM "choiceValues" FK "__FK_choiceValues" ArrayValueAlias "@Value")

        FROM "definition" PK "__KEY_definition" FK "__FK_definition")

    FROM "customProperties" PK "__KEY_customProperties" FK "__FK_customProperties"),

    (SELECT

        "id" AS "id_u1",

        "userId",

        "userDirectory",

        "name" AS "name_u0",

        "privileges" AS "privileges_u0",

        "__FK_owner"

    FROM "owner" FK "__FK_owner"),

    (SELECT

        "id" AS "id_u2",

        "name" AS "name_u1",

        "privileges" AS "privileges_u1",

        "__FK_tags"

    FROM "tags" FK "__FK_tags"),

    (SELECT

        "id" AS "id_u3",

        "name" AS "name_u2",

        "privileges" AS "privileges_u2",

        "__FK_stream"

    FROM "stream" FK "__FK_stream")

FROM JSON (wrap on) "root" PK "__KEY_root";

//Application name and guid

[ApplicationRoot]:

LOAD

    [id_u4] AS [AppGUID],

    [name_u3] As AppName,

    [__KEY_root] AS [AppKey]

RESIDENT RestConnectorMasterTable

WHERE NOT IsNull([__KEY_root]) and [id_u4] = '$(vMe)';

//Custom Property Values

//at this point you will have all custom property values assiged to the app.

Left Join(ApplicationRoot)

LOAD

    [__FK_customProperties] AS [AppKey],

    [__KEY_customProperties] AS [CustomPropertyKey],

    [value] AS [CustomPropertyValue]

RESIDENT RestConnectorMasterTable

WHERE NOT IsNull([__FK_customProperties]);

//Removing all custom property values except the environment property.

Inner Join(ApplicationRoot)

LOAD

    [__FK_definition] AS [CustomPropertyKey],

    [name] AS [CustomPropertyName]

RESIDENT RestConnectorMasterTable

WHERE NOT IsNull([__FK_definition]) and name = '$(vEnvironmentPropertyName)';

DROP TABLE RestConnectorMasterTable;

Let vEnvironmentCount = Fieldvaluecount('CustomPropertyValue');

If vEnvironmentCount = 1 then

   Let vEnvironmentName = Fieldvalue('CustomPropertyValue',1);

else

   //decision: we can do a number of things here

   //          defaulting to production but we could fail the script or whatever

   // xet vEnvironmentName = 'FAIL FAIL FAIL';

   Let vEnvironmentName = 'Production';

End if

drop table ApplicationRoot;

trace running with $(vEnvironmentName) data !!!;