Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
Is possible get space name in a variable throught script in the app?
I need detect this for to do one action or another depending on the space.
Thank you and regards!
Sub GetSpaceName(tenantFQDN,restConnection)
LET appName = DocumentName();
SET spaceName;
LIB CONNECT TO '$(restConnection)';
RestConnectorMasterTable:
SQL SELECT
"__KEY_root",
(SELECT
"spaceId",
"__FK_attributes"
FROM "attributes" PK "__KEY_attributes" FK "__FK_attributes")
FROM JSON (wrap on) "root" PK "__KEY_root"
WITH CONNECTION (
URL "https://$(tenantFQDN)/api/v1/apps/$(appName)"
);
[attributes]:
LOAD
[spaceId]
RESIDENT RestConnectorMasterTable
WHERE NOT IsNull([__FK_attributes]);
DROP TABLE RestConnectorMasterTable;
Let spaceId = Peek('spaceId');
drop Table attributes;
// If app is in a space
if '$(spaceId)' <> '' then
RestConnectorMasterTable:
SQL SELECT
"name",
"__KEY_root"
FROM JSON (wrap on) "root" PK "__KEY_root"
WITH CONNECTION (
URL "https://$(tenantFQDN)/api/v1/spaces/$(spaceId)"
);
[root]:
LOAD
[name]
RESIDENT RestConnectorMasterTable
WHERE NOT IsNull([__KEY_root]);
DROP TABLE RestConnectorMasterTable;
let spaceName = Peek('name');
DROP TABLE root;
end if;
End Sub;
And later to use variable: $(spaceName) for compare with your name space.
Sub GetSpaceName(tenantFQDN,restConnection)
LET appName = DocumentName();
SET spaceName;
LIB CONNECT TO '$(restConnection)';
RestConnectorMasterTable:
SQL SELECT
"__KEY_root",
(SELECT
"spaceId",
"__FK_attributes"
FROM "attributes" PK "__KEY_attributes" FK "__FK_attributes")
FROM JSON (wrap on) "root" PK "__KEY_root"
WITH CONNECTION (
URL "https://$(tenantFQDN)/api/v1/apps/$(appName)"
);
[attributes]:
LOAD
[spaceId]
RESIDENT RestConnectorMasterTable
WHERE NOT IsNull([__FK_attributes]);
DROP TABLE RestConnectorMasterTable;
Let spaceId = Peek('spaceId');
drop Table attributes;
// If app is in a space
if '$(spaceId)' <> '' then
RestConnectorMasterTable:
SQL SELECT
"name",
"__KEY_root"
FROM JSON (wrap on) "root" PK "__KEY_root"
WITH CONNECTION (
URL "https://$(tenantFQDN)/api/v1/spaces/$(spaceId)"
);
[root]:
LOAD
[name]
RESIDENT RestConnectorMasterTable
WHERE NOT IsNull([__KEY_root]);
DROP TABLE RestConnectorMasterTable;
let spaceName = Peek('name');
DROP TABLE root;
end if;
End Sub;
And later to use variable: $(spaceName) for compare with your name space.