Scripting Prepare query

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

I have a conditional field on a Schema, so when a value is selected on the trigger field, the conditional field is going to be hidden and disabled. When I publish the content, a rule is executed and send the JSON payload to an endpoint with that field.

Expected behavior

When the conditional field is disabled and hidden, I want the rule to not send that field on the JSON payload.

Minimal reproduction of the problem

  • Create a schema
  • Add a string field
  • Add a select field with two values
  • On the More tab on the schema, select the select field as a conditional to disable and hide the string field
  • Add a rule to send the data to an endpoint
  • Add a new content to the schema
  • Select on the select input the value to hide and disable the field, and click on save. Then publish the content
  • When the content is publish it should execute the Rule to send the data
  • On the data payload should not have the string field

Environment

App Name:

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

Version: dev-7133

Browser:

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

Others:
We saw that there is a scripting tab were we can prepare a query. I was looking into the documentation but couldn’t see how this works. This is valid for rules? Or this only works for external requests?

Thanks for your support

The rule script does not have access to the schema.

But If I understand you properly, you have two fields, e.g.

  • Type (String, Either “Article” or “News”)
  • Description (String, Hidden when Type == “News”)

So you could do something like this in your rule script::

if (event.data.type.iv == 'News') {
   delete event.data.description;
}

return JSON.stringify(event.data);

The scripts on the schema tab are not relevant for rules.

1 Like

Thank you Sebastian, you save my day!!

1 Like