JavaScript SDK for developing over the Kissflow lowcode platform
Install the SDK as a module: npm i @kissflow/lowcode-client-sdk
Then import into your project:
import KFLowcodeSDK from "@kissflow/lowcode-client-sdk";
const kf = KFLowcodeSDK();
SDK can also be loaded directly into HTML by adding:
<script src="https://cdn.jsdelivr.net/npm/@kissflow/lowcode-client-sdk@1/dist/kflowcode.sdk.js"></script>
<!-- or -->
<script type="module" src="https://cdn.jsdelivr.net/npm/@kissflow/lowcode-client-sdk@1/dist/kflowcode.sdk.module.js"></script>
Then SDK can be initialized anywhere by declaring:
const kf = window.KF();
Note: These function can be used only on button and other events inside the kissflow forms Use Table:: as a prefix while using TableId
kf.currentForm.getField(fieldId).then((res) => {...})
// or
let value = await kf.currentForm.getField(fieldId)
kf.currentForm.updateField({ fieldId_1: fieldValue, fieldId_2: fieldValue });
Appends row details to the end of table.
kf.currentForm.addTableRow("tableId", { columnId1: value, columnId2: value });
kf.client.showInfo(message);
kf.client.showConfirm({ title, content });
kf.client.redirect(url);
kf.getComponent(componentId).refresh();
Application variables has global context to application,
let value = await kf.app.getVariable("variableId");
let value = await kf.app.setVariable("variableId", value);
// or
await kf.app.setVariable({
variableId_1: "value_1",
variableId_2: 3345
});
Note: Page Input parameters are optional.
let pageInputParameters = {
param1: value,
param2: value
};
kf.app.openPage(pageId, pageInputParameters);
let value = await kf.app.page.getParameter();
let popupPage = await kf.app.page.openPopup(pageId, { inputParam1: 2 }, { w: 50; h: 50 })
Note: openPopup method returns the popup page class using which we can chain other functions in page, for eg: (cont. from above code snippet)
let variableName = await popupPage.getVariable("variableName");
popupPage.onClose(() => {});
kf.app.page.onClose(() => {});
// or
let popupPage = await kf.app.page.openPopup(pageId, { inputParam1: 2 }, { w: 50; h: 50 })
popupPage.onClose(() => {
console.log("popup onclose");
// ...
});
Returns the current account, user, page, and application.
kf.getContext().then((ctx) => {...})
// or
let ctx = await kf.getContext()
/*
returns the context object like.
ctx = {
app: {_id },
page: { _id },
user: { Name, Email, UserType, _id },
account: { _id }
}
*/
Fetch any external api & other kissflow api using this method.
Note: This method has a limit of 10 seconds for an api call
kf.api(url, config).then((res) => {...})
// or
let resp = await kf.api(url, config)
Listens for changes in parameter given to custom components in lowcode application.
kf.watchParams(function (data) {
console.log(data);
});
kf.formatter.toDate("08-24-2021").then((res) => {...})
// or
let value = await kf.formatter.toDate("08-24-2021");
kf.formatter.toDateTime("2021-08-26T14:30").then((res) => {...})
// or
let value = await kf.formatter.toDateTime("2021-08-26T14:30");
kf.formatter.toNumber("1,00,000.500000").then((res) => {...})
// or
let value = await kf.formatter.toNumber("1,00,000.500000");
kf.formatter.toCurrency("1,00,000.500000", "USD").then((res) => {...})
// or
let value = await kf.formatter.toCurrency("1,00,000.500000", "USD");
kf.formatter.toBoolean("yes").then((res) => {...})
// or
let value = await kf.formatter.toBoolean("yes");
let value = await kf.formatter.toBoolean("1");
let value = await kf.formatter.toBoolean("true");
let value = await kf.formatter.toBoolean("no");
let value = await kf.formatter.toBoolean("0");
let value = await kf.formatter.toBoolean("false");