Hi,
I have a component that I’m using within a schema. I’m writing an update script to update a value of the component, but am getting an error message from the editor when the script is executed.
This script code, which takes the existing value and puts it into a ‘debug’ field, works fine:
ctx.data.debug.iv = ctx.data.sections.iv[0].myguid;
replace();
However, when I try to assign a new value I get an error message. The code I’m using to assign the value is:
ctx.data.sections.iv[0].myguid = “Barton”;
replace();
The error message I get is from the editor when I attempt to save the data is:
Validation error.
Failed to execute script with Javascript error: null.
Any help would be greatly appreciated!
is it a component or components field?
Hi, it is definitely a bug. I will provide a fix.
But after the fix your script need to look like this:
var components = ctx.data.sections.iv;
var component = components[0];
component.test = "Hello";
ctx.data.sections.iv = components;
replace();
The reason is that the Squidex uses assignments to properties or property languages (iv is also one) to detect, whether a change has happened.
1 Like
Thanks, Sebastian.
And just to answer your earlier question, it is a components (plural) field.
You can try docker tag dev-6562
if you want.
I’m using the Squidex cloud.
Sorry. Will be deployed tomorrow.
It is deployed now to the cloud.
Just did a quick test and it seems to be working fine now. Thanks for the help!
Btw, this is part of my effort to assign GUIDs (using your new function) to various elements in my schemas.
1 Like
system
Closed
December 16, 2021, 3:43pm
11
This topic was automatically closed after 2 days. New replies are no longer allowed.