How to use the Create Content rule

I have…

I’m submitting a…

  • [ ] Regression (a behavior that stopped working in a new release)
  • [ ] Bug report
  • [ ] Performance issue
  • [x ] Documentation issue or request

Current behavior

There is no documentation for how to use the “Create Content” rule action. When setting this up, there is an empty text box. The documented examples relate to other action types. I am able to figure out webhooks, email and a few other items from the documentation.

Expected behavior

I would like to know how to implement this feature.

Minimal reproduction of the problem

Search for “Squidex Create Content” and note that none of the documentation speaks to this implementation.

Environment

App Name: n/a

  • [ ] Self hosted with docker
  • [ ] Self hosted with IIS
  • [ ] Self hosted with other version
  • [x ] Cloud version

Version: “version”: “7.0.2149.0”

Browser:

  • [ x ] Chrome (desktop)
  • [ ] Chrome (Android)
  • [ ] Chrome (iOS)
  • [ ] Firefox
  • [ ] Safari (desktop)
  • [ ] Safari (iOS)
  • [ ] IE
  • [ ] Edge

Others:
I also found the “Rules Formatting” section difficult to follow, in general, and had to figure out how to make things work by trial and error.

The data must be a data structure in the same format that you have received from the content API.

e.g. something like this: https://docs.squidex.io/02-documentation/introduction-and-use-case#json-structure

And the schema is a schema name.

Thanks again!

To add additional details that I found helpful in figuring this out:

  • Create at least one sample Content item for the data schema you wish to populate for reference.
  • Use the “data” object of that content as your sample.
  • The “Data” section of the Create Content action must be properly formatted JSON with the same exact fields as are in the data schema (same as the sample)
  • do not include the data property, but use the fields nested below that level
  • The basic idea is to fill in the text box with the JSON content that will populate the “data” property of the schema.

Follow up…how do I include JS? I want to set the year field in a schema to the current year. I’ve tried something like:

Script(var strYear=new Date().getFullYear().toString();
return { "year": strYear })

and
{ "year": new Date().getFullYear().toString() }

and
{ "year": formatDate($TIMESTAMP_DATE, "YYYY")

all fail. The script doesn’t work at all (throws error) and the Timestamp one sets the year to
null 'YYYY')}

I think I figured it out. You have to click the “script” tab and then you can use scripts. They don’t need the Script() wrapper as shown in the document.

For anyone else struggling with this, to use scripts, you must click the Script tab in the middle and use Javascript in the box.

I’m going to submit a feature request to update the formatting for selected tabs for this. I’ve been playing with this for about 6 hours over two days and didn’t think those tabs did anything at all.

1 Like

Yes,the script wrapper is now added by default.

1 Like