Hello
Feature(s) impacted
collection.addAction()
Observed behavior
I’ve added a smart action in my test environment, here’s the code below
collection.addAction('Traiter la demande de remboursement', {
scope: 'Single',
form: [
{
label: 'Traiter la demande',
type: 'Enum',
enumValues: ['Valider', 'Refuser', 'A modifier'],
isRequired: true,
},
{
label: 'montant',
type: 'Number',
value: async context => {
const refundRequestData = await context.getRecord(['amount']);
const refundStatus = await context.formValues['Traiter la demande'];
if (refundStatus === 'Valider') {
return refundRequestData.amount;
}
return null;
},
isRequired: true
},
{
label: 'commentaire',
type: 'String',
widget: 'TextArea',
placeholder: "Commentaire visible au client, attention en cas de suppression de l'ancien message ce dernier sera perdu. Privilégiez un saut à la ligne si vous souhaiter compléter le message.",
defaultValue: async context => {
const refundRequestData = await context.getRecord(['agentComment']);
if (refundRequestData.agentComment) {
return refundRequestData.agentComment;
}
return null;
},
isRequired: async context => {
const refundStatus = context.formValues['Traiter la demande'];
if (refundStatus === 'Refuser') {
return true;
}
return false;
}
},
],
execute: async (context, resultBuilder) => {
console.log(context)
return resultBuilder.success('Amount charged!');
},
});
Expected behavior
Using execute and then displaying the log and resultBuilder
Failure Logs
In web log
In my dev log
Is it better to use an app.use()
to receive the call, or is there a problem with my addAction
? Because I don’t see any problem using the smart action
Context
- Project name: Nostrum Care v3
- Team name: Op
- Environment name: Local
- Agent (forest package) name & version:
“@forestadmin/agent”: “^1.43.0”,
“@forestadmin/datasource-sequelize”: “^1.5.21”,
“@forestadmin/datasource-sql”: “^1.0.0”,
“dotenv”: “^16.0.1”,
“pg”: “^8.8.0”,
“sequelize”: “^6.33.0”,
“stripe”: “^14.17.0” - Database type: Postgresql
Thank you in advance for your help !!