Hey,
We have a orders, and on the orders, we have a smart action to add order items. Order items have a kind, that is a select field to pick from.
There are 3 kinds:
- Coliving Damage → this kind is only available when the order is of a specific kind (5)
- Manual Coliving & Manual Service → the rest of the time, these kinds should be available
It happens that sometimes, instead of having Manual Coliving & Manaul Service to be available on the select field, we have the Coliving Damage type.
When this problem happen, our only solution is to restart the Forest pod so that it goes back to place. This solution works great, but we don’t know why Forest derail like this…
The code of the action looks something like this:
{
name: 'Add credit/debit',
type: 'single',
endpoint: '/forest/actions/orders/add_order_item',
fields: [{
field: 'kind',
type: 'Enum',
enums: ['Manual Service', 'Manual Coliving'],
isRequired: true,
}, {
field: 'description',
type: 'String',
isRequired: true,
}, {
field: 'price',
description: 'Price in € without VAT. If you\'re adding room damages to a deposit refund, please put the price including VAT.',
type: 'Number',
isRequired: true,
}, {
field: 'vat',
description: 'You can add any rate when the kind is service. Otherwise, fill in 0',
type: 'Number',
isRequired: true,
}],
hooks: {
load: async ({ fields, request }) => {
const id = request.body.data.attributes.ids[0]
const totalPrice = await computeOrderTotalPrice(id)
const ordersRes = await sequelize.query(readQueryLocal(`${__dirname}/sql/fields/kind_type.sql`), {
replacements: { order_id: id },
type: sequelize.QueryTypes.SELECT,
})
const kindType = await getKindType(ordersRes, totalPrice)
if (kindType === 5) {
const kindField = fields.find(field => field.field === 'kind')
kindField.enums = ['Coliving Damage']
}
return fields
},
},
Any idea how we could correct this so that the behaviour is constant and that we don’t have to restart our pod?
Thanks a lot!