Payload Liquid logic

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

Expected behavior

Minimal reproduction of the problem

Environment

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

Version: [VERSION]

Browser:

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

Others:
Hi Team
I am trying to evaluate the tool and have a particular scenario.
Firstly, is it possible to make a required field optional based on the value of some other field.
For Ex, City field is set to Required. But if someone selects Germany as a country from dropdown, then make City field as an optional field.
I looked at using Scripts -> Create option.

One way is to make the city field non-required and put the login in scripts -> create that if Country !=
“Germany” then
var data = ctx.data;
if (data.Country.iv !== "Germany ") {
reject(‘City is required’);
}
But in actual fact, I have many fields, so above logic will quite complicated to handle.

Secondly, pls can you guide if in Payload in Rules, based on selected year, I am trying to auto populate the data for that for other years.

Example: User provide sales figure for year 2020 and 2023.
I want to copy the sales figure of 2020 to 2021 and 2022 and sales figure of 2023 to 2024 and 2025.
Basically forward fill the data.

{% for pu in event.data.YearlyData.iv %}
{
“Year”: “{{pu.Year}}”,
“Sales”:"{{pu.Sales}}"
}

Any help would be greatly appreciated !
Thanks

About your first question:

You can have a look to the field rules in the “More” section under schemas.

image

About liquid: I am not sure, I have to dig into the template engine as well. Perhaps you can use a normal for loop or so?

Thanks a lot @Sebastian

1 Like