Qlik Community

Qlik Sense Integration, Extensions, & APIs

Discussion board where members can learn more about Integration, Extensions and API’s for Qlik Sense.

Announcements
If you are a Qlik Insight Bot user, join this collaborative group: JOIN GROUP
Highlighted
New Contributor III

.net sdk how to update the selected values of a bookmark

Hello,

I'm able to get the bookmarks list and the right setanalysis values, using this simple code:

var layout = app.GetAppLayout();
var bkms = app.GetBookmarkList();

foreach (var bkm in bkms.Items)
{
     var bkmData = bkm.Data;
     TextHelper.WriteLine(1,$"{bkmData.Title} > {bkmData.SelectionFields}");

     var sa = app.GetSetAnalysis("$", bkm.Info.Id);
     TextHelper.WriteLine(2, $"Bookmark filters: {sa}");                
}

 

In the specific case, I have a field named "Anno" (year) set to 2019. 
I would like to change it to 2020 by code. Is this possible? I cannot find any methos like "app.SetSetAnalysis" or something to update the setanalysis of that specific bookmark.

Can you post an example?

Thank you

5 Replies
Highlighted
Partner
Partner

Re: .net sdk how to update the selected values of a bookmark

hello,

So you want to change Bookmark or want to change Field? 

Highlighted
Partner
Partner

Re: .net sdk how to update the selected values of a bookmark

hello,

i found one solution just check it out,

if you have kpi then please try this steps

1.  in engine api select one app after selecting app you have one method called getObject  and pass this JSON

{
"handle": 1,
"method": "GetObject",
"params": {
"qId": "JjUqzF"      // You have to pass object id of kpi
},
"outKey": -1,
"id": 4
}

2.  Use SetProperties  method and pass this JSON and change your expression

{
"handle": 2,
"method": "SetProperties",
"params": {
"qProp": {
"qInfo": {
"qId": "JjUqzF",
"qType": "kpi"
},
"qExtendsId": "",
"qMetaDef": {},
"qStateName": "",
"qHyperCubeDef": {
"qStateName": "",
"qDimensions": [],
"qMeasures": [
{
"qLibraryId": "",
"qDef": {
"qLabel": "",
"qDescription": "",
"qTags": [],
"qGrouping": "N",
"qDef": "count(EmployeeCount)",  // change your date here 
"qNumFormat": {
"qType": "U",
"qnDec": 10,
"qUseThou": 0,
"qFmt": "",
"qDec": "",
"qThou": ""
},
"qRelative": false,
"qBrutalSum": false,
"qAggrFunc": "",
"qAccumulate": 0,
"qReverseSort": false,
"qActiveExpression": 0,
"qExpressions": [],
"qLabelExpression": "",
"autoSort": true,
"cId": "ZFJMEf",                                          // change this CID as object Id
"numFormatFromTemplate": true,
"measureAxis": {
"min": 0,
"max": 100
},
"conditionalColoring": {
"useConditionalColoring": false,
"singleColor": 3,
"paletteSingleColor": {
"index": 6
},
"segments": {
"limits": [],
"paletteColors": [
{
"index": 6
}
]
}
}
},
"qSortBy": {
"qSortByState": 0,
"qSortByFrequency": 0,
"qSortByNumeric": -1,
"qSortByAscii": 0,
"qSortByLoadOrder": 1,
"qSortByExpression": 0,
"qExpression": {
"qv": ""
},
"qSortByGreyness": 0
},
"qAttributeExpressions": [],
"qAttributeDimensions": [],
"qCalcCond": {
"qv": ""
},
"qCalcCondition": {
"qCond": {
"qv": ""
},
"qMsg": {
"qv": ""
}
}
}
],
"qInterColumnSortOrder": [
0
],
"qSuppressZero": false,
"qSuppressMissing": true,
"qInitialDataFetch": [
{
"qLeft": 0,
"qTop": 0,
"qWidth": 500,
"qHeight": 10
}
],
"qReductionMode": "N",
"qMode": "S",
"qPseudoDimPos": -1,
"qNoOfLeftDims": -1,
"qAlwaysFullyExpanded": false,
"qMaxStackedCells": 5000,
"qPopulateMissing": false,
"qShowTotalsAbove": false,
"qIndentMode": false,
"qCalcCond": {
"qv": ""
},
"qSortbyYValue": 0,
"qTitle": {
"qv": ""
},
"qCalcCondition": {
"qCond": {
"qv": ""
},
"qMsg": {
"qv": ""
}
},
"qColumnOrder": [],
"qLayoutExclude": {
"qHyperCubeDef": {
"qStateName": "",
"qDimensions": [],
"qMeasures": [],
"qInterColumnSortOrder": [],
"qSuppressZero": false,
"qSuppressMissing": false,
"qInitialDataFetch": [],
"qReductionMode": "N",
"qMode": "S",
"qPseudoDimPos": -1,
"qNoOfLeftDims": -1,
"qAlwaysFullyExpanded": false,
"qMaxStackedCells": 5000,
"qPopulateMissing": false,
"qShowTotalsAbove": false,
"qIndentMode": false,
"qCalcCond": {
"qv": ""
},
"qSortbyYValue": 0,
"qTitle": {
"qv": ""
},
"qCalcCondition": {
"qCond": {
"qv": ""
},
"qMsg": {
"qv": ""
}
},
"qColumnOrder": []
}
}
},
"showTitles": false,
"title": "",
"subtitle": "",
"footnote": "",
"showDetails": false,
"showMeasureTitle": true,
"textAlign": "center",
"fontSize": "M",
"useLink": false,
"sheetLink": "",
"openUrlInNewTab": true,
"visualization": "kpi"
}

}
}

 

4. if you want this JSON for other like barchart or anything just use GetProperties method so you can get this json.. use this json in set properties  with your change expression.. 

 

if you need More help just reply 

Thanks Regard,

Harsh Gohil

 

Highlighted
New Contributor III

Re: .net sdk how to update the selected values of a bookmark

I want to change the year's value of a bookmark from 2019 to 2020.

I can't find any method to change the bookmark's filter values. I can only get the values using the GetSetAnalysis(bookmarkId) method.

Do you think it is possible to update a bookmark via the .net sdk? I thought it would be quite simple but it's not 😞

Thank you

Highlighted
Partner
Partner

Re: .net sdk how to update the selected values of a bookmark

hello,

I'm not sure but i think its not possible .. you have to create new bookmark .

Thanks Regards,

Harsh Gohil

Highlighted
Employee
Employee

Re: .net sdk how to update the selected values of a bookmark

This is not possible I'm afraid. There are no API endpoints that allow you to modify an existing bookmark. The only thing you can do is to create a new one based on the selection state of the engine.

However, I think you should be able to automate the flow by doing something like this:

  • Apply the bookmark
  • Get its set analysis expression
  • Modify the expression
  • Clear selections
  • Apply the new, modified expression as a selection
  • Create a new bookmark based on current selection state.

It's an awkward flow, and you'll get a new ID for the bookmark, but perhaps that can help you along.