Skip to content

Instantly share code, notes, and snippets.

View rjriel's full-sized avatar

Rey Riel rjriel

View GitHub Profile
@rjriel
rjriel / main.html
Last active September 18, 2017 21:12
Functions for API Training
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title></title>
<link rel="stylesheet" href="https://playground.qlik.com/playground/resources/autogenerated/qlik-styles.css">
</head>
<body>
<script type="text/javascript" src="https://playground.qlik.com/playground/resources/assets/external/requirejs/require.js"></script>
<script type="text/javascript" src="/node_modules/playground-js-api/dist/playground-js-api.min.js"></script>
@rjriel
rjriel / acquire_selection_state.js
Last active January 20, 2022 07:11
The basics of the Capability API's
// https://help.qlik.com/en-US/sense-developer/September2018/Subsystems/APIs/Content/Sense_ClientAPIs/CapabilityAPIs/SelectionAPI/qlik-selectionState-interface.htm
// here is a basic example of acquiring and working with the current selection
// state. Here we can get a list of all fields that have selections and what
// values have been selected for each field
var selectionState = app.selectionState()
var listener = function() {
var selections = selectionState.selections
// each item in the selectionState.selections is a field
const fs = require('fs')
const path = require('path')
require('dotenv').config()
const { dataFile, saveDirectory} = process.env
while(true) {
try {
fs.renameSync(dataFile, path.join(saveDirectory,`${Date.now()}.csv`))
} catch(e) {}
version: "2"
services:
engine:
image: qlikcore/engine:12.368.0
command: -S AcceptEULA=yes -S DocumentDirectory=/docs -S EnableFilePolling=1
ports:
- "19076:9076"
volumes:
- ./core-docs:/docs
engine: localhost:19076
app: Qonnections2019.qvf
script: ./load-script.qvs
connections:
data:
connectionstring: /data
type: folder
Simulator:
LOAD
*
FROM [lib://data/processed/ski-data.csv]
(txt, utf8, embedded labels, delimiter is ',');
Simulator:
ADD LOAD
[Race ID],
Badge,
await qixApp.createObject({
qInfo: { qId: "Badge", qType: "GenericObject" },
badge: "0",
raceId: ""
})
await qixApp.doSave()
badgeObject = await qixApp.getObject("Badge")
badgeObject.on("changed", async () => {
checkBadge()
let results = csvLoad(readDirectory, badgeValue, raceValue)
...
fs.writeFileSync(unprocessedFile, results.join("\n"))
const reload = await qixApp.doReloadEx({ qPartial: true })
await qixApp.doSave()
if (finishedFound) {
...
const badgePatchProperties = [
{
qOp: "replace",
qPath: "/badge",
qValue: "0"
},
{
const raceId = uuidv4()
const badgePatchProperties = [{
qOp: "replace",
qPath: "/badge",
qValue: participant.badge
},
{
qOp: "replace",
qPath: "/raceId",
qValue: `"${raceId}"`