Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Qlik Sense Extension get right Object Id in all Situations (vanilla, master item, story)
function getObjectId(scope: any): Promise<string> {
return new Promise((resolve, reject) => {
try {
let objectId: string = "";
if (scope.layout.sourceObjectId) {
// story
objectId = scope.layout.sourceObjectId;
scope.component.model.app.getObject(objectId)
.then( ( obj: EngineAPI.IGenericObject ) => {
obj.getProperties()
.then( ( props: EngineAPI.IGenericProperties ) => {
if (props.qExtendsId) {
// extension as master item
objectId = props.qExtendsId;
}
resolve(objectId);
})
.catch( ( error ) => {
console.error( error )
reject(error);
});
})
.catch( ( error ) => {
console.error( error )
reject(error);
});
} else {
// normal extension or extension as master item
objectId = scope.layout.qExtendsId ? scope.layout.qExtendsId : scope.layout.qInfo.qId;
resolve(objectId);
}
} catch (error) {
console.error(error);
reject(error);
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.