Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
My overall goal is to do this:
1) Using .Net scripting, create a new bookmark with a filter determined from the .Net app
2) Send a user's browser to that bookmark.
Below is my code related to creating a bookmark. It works, except I have not been able to successfully create an expression for bookmarkProperties.SelectionFields.Where(). In my case, I want to create a filter WHERE <column name> = <value>
Regarding item #2, I am using code like this -- I am not clear how I would direct the browser to a specific bookmark.
String webAddress = "https://<Server>/sense/app/<AppID>/sheet/<SheetID>";
Process.Start(webAddress);
Thank you
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Qlik.Engine;
using Qlik.Sense.Client;
System.Uri qlikURI = new System.Uri("https://<Server Name>/");
ILocation location = Qlik.Engine.Location.FromUri(qlikURI);
using (IHub hub = location.Hub())
{
IAppIdentifier appID = location.AppWithName("<App Name");
IApp application = location.App(appID);
IEnumerable<ISheet> sheets = application.GetSheets();
ISheet thisSheet = null;
IBookmark bookmark = null;
foreach (ISheet activeSheet in sheets)
{
if (activeSheet.SheetMetaData.Title == "<Sheet Name>") {
thisSheet = activeSheet;
}
}
if (thisSheet != null) {
Qlik.Sense.Client.BookmarkProperties bookmarkProperties = new BookmarkProperties();
bookmarkProperties.SheetId = thisSheet.Id;
bookmarkProperties.Title = "New Bookmark";
bookmarkProperties.CreationDate = "1/1/2014";
//bookmarkProperties.SelectionFields.Where();
bookmark = application.CreateBookmark("New Bookmark 1",bookmarkProperties);
}
}
I would first ask you to use lists instead of instances of objects, that way you can read the properties of generic objects before you instantiate them.
Example for sheetList:
ISheetList sheetList = application.GetSheetList();
foreach (ISheetObjectViewListContainer item in sheetList.Items)
{
Console.WriteLine(item.Data.Title);
}
This doesn't solve your problems but will make your program faster, and you can react on changes in the lists.
To create a Bookmark that reflects an application selection state you need to set the selection state before you create the bookamark.
System.Uri qlikURI = new System.Uri("https://<Server Name>/");
ILocation location = Location.FromUri(qlikURI);
IAppIdentifier appID = location.AppWithName("<App Name>");
using (IApp application = location.App(appID))
{
ISheetList sheetlist = application.GetSheetList();
ISheet thisSheet = sheetlist.Items
.First(o => o.Data.Title.Equals("<Sheet Name>"))
.As<Sheet>();
IAppField field1 = application.GetAppField("<Field1>");
field1.SelectAll();
IAppField field2 = application.GetAppField("<Field2>");
field2.SelectValues(new[] { 1, 45, 77 }, toggleMode: false, softLock: false);
var bookmarkProperties = new BookmarkProperties
{
SheetId = thisSheet.Id,
Title = "New Bookmark",
CreationDate = "2014-10-07T19:43:16.523Z",
SelectionFields = "<Field1>, <Field2>"
};
var bookmark = application.CreateBookmark("<Bookmark1>", bookmarkProperties);
}
The SelectionFields Property is a comma separated string with the Fields used in the bookmark, this is mainly used to show information in the Qlik Sense client.
A solution to your second question is currently not supported, but could be emulated using extensions.
define(["jquery","qlik"], function($, qlik) {
paint : function() {
qlik.currApp().bookmark.apply("<Bookmark1>");
}
});
Please see the Toolbar Extension Example for more information, https://help.qlik.com/sense/en-us/developer/index.html#../Subsystems/Workbench/Content/CodeExamples/...
Regards,
Johan Tejle
I would first ask you to use lists instead of instances of objects, that way you can read the properties of generic objects before you instantiate them.
Example for sheetList:
ISheetList sheetList = application.GetSheetList();
foreach (ISheetObjectViewListContainer item in sheetList.Items)
{
Console.WriteLine(item.Data.Title);
}
This doesn't solve your problems but will make your program faster, and you can react on changes in the lists.
To create a Bookmark that reflects an application selection state you need to set the selection state before you create the bookamark.
System.Uri qlikURI = new System.Uri("https://<Server Name>/");
ILocation location = Location.FromUri(qlikURI);
IAppIdentifier appID = location.AppWithName("<App Name>");
using (IApp application = location.App(appID))
{
ISheetList sheetlist = application.GetSheetList();
ISheet thisSheet = sheetlist.Items
.First(o => o.Data.Title.Equals("<Sheet Name>"))
.As<Sheet>();
IAppField field1 = application.GetAppField("<Field1>");
field1.SelectAll();
IAppField field2 = application.GetAppField("<Field2>");
field2.SelectValues(new[] { 1, 45, 77 }, toggleMode: false, softLock: false);
var bookmarkProperties = new BookmarkProperties
{
SheetId = thisSheet.Id,
Title = "New Bookmark",
CreationDate = "2014-10-07T19:43:16.523Z",
SelectionFields = "<Field1>, <Field2>"
};
var bookmark = application.CreateBookmark("<Bookmark1>", bookmarkProperties);
}
The SelectionFields Property is a comma separated string with the Fields used in the bookmark, this is mainly used to show information in the Qlik Sense client.
A solution to your second question is currently not supported, but could be emulated using extensions.
define(["jquery","qlik"], function($, qlik) {
paint : function() {
qlik.currApp().bookmark.apply("<Bookmark1>");
}
});
Please see the Toolbar Extension Example for more information, https://help.qlik.com/sense/en-us/developer/index.html#../Subsystems/Workbench/Content/CodeExamples/...
Regards,
Johan Tejle
Thank You, that has gotten me very far.
I am trying to accomplish the same thing. Can you share if you are able to send user directly to the bookmark via URL?
Hi!
Is it possible to do this throw a QS Extension? I want to create or modify bookmarks but without doing the seleccions, and what I came through is that is only possible with JSON api, am i right?
My real final goal is to convert several variables in several bookmarks, all with only with button on the QS App.
Thanks!
PAblo
Hi,
Does anyone know how to get Bookmark selection fields filter definitions?
Say I have a BM created from App UI. I can get all below but the filter definitions something like {<[Time Period]={'YTD'}>}