
One thing that I’ve always like doing to test things, specifically EntitySchemaQuery tests, was to simply test things out in the browser console. You could easily create an EntitySchemaQuery and test it without needing to go add it to a page, refresh, etc. Plus, it makes it easy to look at some data to troubleshoot without needing to look in the database etc.
However, for testing queries in the browser console with the Creatio DevKit SDK, there’s two things to overcome to be able to quickly test in the console. First, you need to get a reference to the DevKit, it’s not globally available like using Ext to create an EntitySchemaQuery object, and second, most of the functions are async. Luckily, these are easy to overcome. First of all, require is globally available, so we’ll use that to get a reference to the DevKit. Second, we can wrap the test code in an async function so we can await the promises returned by the functions.
This is what you would use in the browser console to test something using the DevKit SDK:
const sdk = require("@creatio-devkit/common"); (async() => { // your test code goes here })();
Here’s a sample you can paste into your console to test the Model query from my last article:
const sdk = require("@creatio-devkit/common"); (async() => { const someAccountId = "ddd2c965-cd43-4c9e-8ee1-9783a5571be8"; const accountModel = await sdk.Model.create("Account"); const accounts = await accountModel.load({ attributes: ["Id", "Name", "Type"], parameters: [{ type: sdk.ModelParameterType.PrimaryColumnValue, value: someAccountId }] }); const account = accounts[0]; console.log(account); })();
Now you can easily test DevKit functions in the console. No need to add to a test page, save, refresh, and repeat.
Subscribe To Our Newsletter
Join our mailing list to receive the latest Infor CRM (Saleslogix) and Creatio (bpm'online) news and product updates!
You have Successfully Subscribed!