Hello,
I would like to know if it is possible for a value to change depending on the value (enums) that we put on it?
example:
I have 3 possible choices of value Valider
, Refuser
and A modifier
When I click for example on Refuse
I would like Montant
just below to be equal to 0
Is it possible ?
Hello @jacques_liao,
Yes, that’s possible. This is called a “smart action hook”.
By specifying the hook property on your smart action declaration, you can define input values based on other input values.
The documentation is here
Regards
Hello,
Thanks for the doc!
So I could see and suddenly I saw that the change hook allowed to do what I wanted, so I tried with my code below
{
name: 'Traiter la demande de remboursement',
type: 'single',
fields: [{
field: 'Traiter_la_demande',
type: 'Enum',
enums: ['Valider', 'Refuser', 'A modifier'],
isRequired: true,
hook: 'onStatusChange'
},
{
field: 'montant',
type: 'Number',
isRequired: true
},
{
field: 'commentaire',
type: 'String',
widget: 'text area',
description: "Ne pas effacer le commentaire existant, faire un saut Ă la ligne pour un nouveau commentaire",
isRequired: false
},
],
hooks: {
load: ({ fields, record }) => {
fields.montant.value = record.amount;
fields.commentaire.value = record.agentComment;
return fields;
},
change: {
onStatusChange: ({ fields, request, changedField }) => {
const amount = fields.find(field => field.field === 'montant');
if (fields.Traiter_la_demande.value === 'Refuser') {
amount.value = 0
}
return fields;
},
}
}
},
]
I put a hook for my fields Traiter_la_demande
and made my conditions, but I get this error.
I may have mistaken something?
Hello,
do you have any news?
Hey @jacques_liao
If I’m not wrong, you are not running the v8 of our agent.
The documentation you should follow is here, since the smart action hook definition has changed between v7 and v8.
Let me know if that helps
1 Like
Hello,
Thank you very much that was the solution !