Console.log in scripting / ctx values

I’m evaluating various headless CMS platforms for a project I’m working on and have spent a few hours with the free cloud version. My initial impression is that this is a very powerful system that can probably do everything I need, but the lack of detailed documentation may make execution very difficult.

For example, the scripting section of the documentation makes reference to the context being available in a ctx value, but I can’t find any detailed description of what’s contained in that value. Can someone point me to additional documentation?

I tried using console.log(JSON.stringify(ctx)) in a script but it appears that console.log is not available from the script. Is that correct? Is there another way?

For my project I want to auto generate a default value for a field in one schema based on the value of a field in a referenced schema. Is this possible?

Thanks in advance to anyone who can answer!

Hello blickstick.

Unfortunately a good description of ctx does not exist, I will add it to the todo list.

Yes, thats right, a console.log is not available, but for testing you could write the JSON.stringify(ctx) to a field, something like

ctx.data.field.iv = jSON.stringify(ctx);
replace();

This is not pssible, the problem is that the scripting engine cannot execute asynchronous code, therefore it is not possible to access a reference.

Hi Sebastian. Thanks very much for your prompt reply, and for the tip about using replace() to take a look at ctx.

Kudos for your work on this project. I really like the design.

1 Like

Hi,
I have improved the documentation about scripting. Let me know what you think.

https://docs.squidex.io/02-documentation/developer-guides/scripting

If you find spelling errors or so, a PR to https://github.com/Squidex/squidex-docs2/blob/master/02-documentation/developer-guides/scripting.md would be awesome.

Hi Sebastian. I just took a quick look at the scripting documentation and it looks great. No obvious errors. I think it will help a lot of people. Thanks!

1 Like

I am working on improvements to the scripting editor right now: