Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Qlik Sense documentation and resources.
Today, I'd like to share with you our current App backup solution using Powershell and Qlik-Cli.
As you know, a production environment needs backups and Qlik Sense Enterprise does not offer such a thing by default so I decided to build a solution.
Using Qlik-Cli for Windows, I put in place a solution that will not only backup my published and unpublished apps but will also create a folder structure to match your streams.
The unpublished apps are backed up inside the "My Work" folder using the app owner's name as a directory name. This allows to easily find the app owner when performing a search in the folders.
Square brackets in the App's name will be removed because you cannot create a file with these characters in Windows.
The script is scheduled using the Windows Task Scheduler with the following command:
Here's the code:
$ErrorActionPreference = "Stop"
Try
{
# set export drive and directory
D:
cd D:\QlikBackups
# connect to the Qlik Server. Replace <ServerName> with your Qlik Sense hostname
Connect-Qlik -ComputerName <ServerName> -UseDefaultCredentials -TrustAllCerts
# Export each apps from the previously defined streams to qvf
Get-QlikStream | % {New-Item -Name ".\$($_.name)" -Force -ItemType 'Directory'} | foreach {Get-QlikApp -filter "stream.name eq '$($_.name)'"} | foreach {Export-QlikApp -skipdata -id $_.id -filename "$($_.stream.name)\$($_.name -replace '[[\]]','').qvf"}
# set the export folder to the My Work area for unpublished apps
cd "D:\QlikBackups\My Work"
# Create a folder structure for all the app owners
Get-QlikApp -full -filter "published eq False" | % {New-Item -Name ".\$($_.owner.userId)" -Force -ItemType 'Directory'}
# Export each app into their folder
Get-QlikApp -full -filter "published eq False" | foreach {Export-QlikApp -skipdata -id $_.id -filename "$($_.owner.userId)\$($_.name -replace '[[\]]','').qvf"}
}
Catch # In case of error, send an email to the Qlik administrators
{
$ErrorMessage = $_.Exception.Message
$FailedItem = $_.Exception.ItemName
$Time=Get-Date
"Error: $FailedItem Message: $ErrorMessage Time: $Time" | out-file d:\log\QlikBackup.log -append
$FailMailParams = @{
To = 'qlikadmin@MyCompany.com'
From = 'MyQlikServer@MyCompany.com'
Port = '25'
SmtpServer = 'smtprelay.MyCompany.com'
Subject = 'MyQlikServer Backup Failure'
Body = "The backup failed. The error message was: $ErrorMessage"
}
Send-MailMessage @FailMailParams
}
My next steps are:
Version 1.7 - A new feature for the front end!
With the latest version, you can now quickly copy the output in expression editor windows using a button.
Check it out on YouTube : https://www.youtube.com/watch?v=CXPMbQSD9mQ
It is very likely that many of you build your data models so that you can easily reuse certain parts, such as dimensions.
Although some development methods such as the Qlik Deployment Framework (QDF) help speed things up, the task of renaming fields when reusing a QVD is still time-consuming.
Let's imagine that a fact table contains 3 customer dimensions and 2 warehouse dimensions and that for each of these dimensions you add a prefix, or that your fields are written in a multilingual way ([Customer/Customer/Cliente]) and you want to get the middle value. You could also use it to rename fields from an SQL database and format everything for a nice front-end result in Qlik.
It's now easier than ever with Sense Field Formatter.
(https://youtu.be/k3HQpJivyZM)
Allows a user to format a list of fields, delimited by commas, into an alias and standardized format.
The user has multiple configuration options to choose from.
When the extension icon is clicked, a popup menu is displayed where the formatting takes place and is pasted into the clipboard.
Will use the alias name (at the right of "AS") from your source fields as your new source fields.
e.g. [SourceField] AS [SourceAlias] -> [SourceAlias] AS [OutputAlias]
The character(s) used to identify the key fields in Qlik. Formatting will be handled differently here as the Prefixing will be done AFTER (the right) the key prefix to avoid breaking the key formatting.
e.g. Prefixing a key field with "Customer." will generate this: [%MyKeyField] AS [%Customer.MyKeyField]
Ignore formatting on Key Fields?
Fields starting with the identified key will NOT be formatted.
Places the comma either at the start or end of the line.
Should the field delimiters be double quotes or square brackets.
Find what: The character(s) you are looking to replace. Multiple characters can be replaced at once.
Replace with: Replace all occurrences of the character(s) in the fields.
Will insert a space before each capital letter in the fields, except for the first character.
e.g. [MyNewField] -> [My New Field]
Applies a case change to all the fields.
Uppercase: Replaces each lowercase letter with a corresponding uppercase char.
Lowercase: Replaces each uppercase letter with a corresponding lowercase char.
Capitalize: The first letter of each word will be in uppercase.
Extract substring components from a parent string field, where the original record fields consist of two or more parts separated by a delimiter.
The function can be used, for example, to extract the column name in a specific language if the field is multilingual.
*e.g. Applying a subfield of 3 with a delimiter of '/' [Client/Cliente/Customer] -> [Customer]
Delimiter: A character within the input text that divides the string into component parts.
Field no: Specifies which of the substrings of the parent string text is to be returned. Use the value 1 to return the first substring, 2 to return the second substring, and so on.
Adds an affix, either placed before the field (prefix) or at the end (suffix). Useful when reusing the same dimension over and over for multiple scenarios.
e.g. Using the customer dimension where a customer may be a Ship To or Bill To customer.
Prefix : [Customer Name] -> [ShipTo.Customer Name]
Suffix : [Customer Name] -> [Customer Name.ShipTo]
Affix: The text that will be used as an affix. Make sure to add a space to your affix if you'd like the new string to remain spaced out.
Installing the plugin
Visit the Store:
Visit my GitHub: https://github.com/MichelLalancette/SenseFieldFormatter
Hi all,
I've been using Qlik SaaS since the first release, Qlik Cloud and whenever I needed to upload new apps, extensions and themes for new or existing deployments, I thought it was a waste of time. With Qlik SaaS's unlimited storage, files have grown tremendously, and with great viewing capabilities, users and apps have followed this trend. My tasks too!
Well, I started studying Qlik SaaS APIs last year (thanks to @Clever_Anjos) and created some scripts to help me do my work on new or existing deployments. These tools were written in Powershell version 7 and can be used on Windows, Mac and Linux. They are:
The scripts are not error-proof, because i'm not a powershell master, and I hope the community can contribute and make this a better tool.
These scripts are avaible at my Git Repository (https://github.com/pbergo/qlik-saas-utils). Enjoy them and write me if you have any trouble.
[]
Pedro Bergo
Hi Qlikers,
Differently from QlikView, Qlik Sense applications are developed on the browser which means that identifying applications based on the interface becomes tricky. The configurations documented here were done to provide clear differentiation between Prod and Dev environments and do not affect the application, they have effect only on the environment. So, the application can be moved from Dev to Prod without any particular change on it.
Best regards,
Huberto Pereira Haidemann