Feature(s) impacted
Adding Action to collection.
Observed behavior
Code source section:
collection.addAction("Statuer", {
scope: "Single",
form: [
{
label: "Nouveau status",
type: "Enum",
enumValues: ["A traiter", "Matcher", "Refuser", "Stand-by"],
isRequired: true,
},
{
label: "WP objet",
type: "String",
value: async context => {
if (context.hasFieldChanged('Nouveau status')) {
const status = context.formValues['Nouveau status'];
if (status === "Matcher") {
const cand = (await context.getRecord(['id_tutor', 'c_user:user_first_name']))
const offre = (await context.getRecord(['id', 'c_besoin:child_id', 'c_besoin:child:address_street', 'c_besoin:child:address_town', 'c_besoin:child:code_postal', 'c_besoin:level', 'c_besoin:user:user_gender', 'c_besoin:user:location_details', 'c_besoin:type', 'c_besoin:nb_seances_hebdo', 'c_besoin:details', 'c_besoin:user:user_last_name', 'c_besoin:user_id', 'c_besoin:child:prenom', 'c_besoin:matieres', 'c_besoin:duree_seance']));
console.log('cand ==', {cand});
console.log('offre ==', {offre});
When I select : “Matcher” I got this error:
Failure Logs
cand == { cand: undefined }
offre == { offre: undefined }
error: [500] POST /forest/_actions/c_candidatures/0/statuer/hooks/change - 1282ms
===== An exception was raised =====
POST /forest/_actions/c_candidatures/0/statuer/hooks/change?{
timezone: Africa/Algiers
}
Body {
data: {
attributes: {
fields: [
{
field: Nouveau status,
type: Enum,
reference: null,
enums: [
A traiter,
Matcher,
Refuser,
Stand-by
],
description: null,
isRequired: true,
value: Matcher,
previousValue: A traiter,
searchValue: null,
widgetEdit: {
name: dropdown,
parameters: {
static: {
values: null
},
isSearchable: false,
placeholder: null
}
},
isReadOnly: null,
hook: changeHook
},
{
field: WP objet,
type: String,
reference: null,
enums: null,
description: null,
isRequired: null,
value: null,
previousValue: null,
searchValue: null,
widgetEdit: {
name: text editor,
parameters: {
placeholder: null
}
},
isReadOnly: null
},
{
field: WP Message,
type: String,
reference: null,
enums: null,
description: null,
isRequired: null,
value: null,
previousValue: null,
searchValue: null,
widgetEdit: {
name: text area editor,
parameters: {
placeholder: null,
rows: 6
}
},
isReadOnly: null
}
],
changed_field: Nouveau status,
ids: [
1065
],
collection_name: c_candidatures,
parent_collection_name: null,
parent_collection_id: null,
parent_association_name: null,
all_records: false,
all_records_subset_query: {
fields[c_candidatures]: photo,prenom,tutorWpLink,action_enum,statut,KYC,total_heures,match_sucess,regularite,ecole,note,comment,tutor_red_flag,
page[number]: 1,
page[size]: 15,
filters: {\aggregator\:\and\,\conditions\:[{\field\:\c_besoin:id\,\operator\:\equal\,\value\:1692},{\field\:\action_enum\,\operator\:\not_equal\,\value\:\Refuser\}]},
sort: -id,
timezone: Africa/Algiers
},
all_records_ids_excluded: [],
smart_action_id: c_candidatures-Statuer,
signed_approval_request: null
},
type: custom-action-hook-requests
}
}
Cannot read properties of undefined (reading 'c_besoin')
TypeError: Cannot read properties of undefined (reading 'c_besoin')
at value (/home/adel/clevermate/clevermate-deploy/clevermate-forest-v2/forest/c_candidatures.ts:152:28)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Promise.all (index 2)
at async /home/adel/clevermate/clevermate-deploy/clevermate-forest-v2/node_modules/@forestadmin/datasource-customizer/src/decorators/actions/collection.ts:313:24
at async Promise.all (index 1)
at async ActionCollectionDecorator.getForm (/home/adel/clevermate/clevermate-deploy/clevermate-forest-v2/node_modules/@forestadmin/datasource-customizer/src/decorators/actions/collection.ts:109:20)
at async ActionRoute.handleHook (/home/adel/clevermate/clevermate-deploy/clevermate-forest-v2/node_modules/@forestadmin/agent/src/routes/modification/action/action.ts:163:18)
at async ErrorHandling.errorHandler (/home/adel/clevermate/clevermate-deploy/clevermate-forest-v2/node_modules/@forestadmin/agent/src/routes/system/error-handling.ts:24:7)
at async Logger.logger (/home/adel/clevermate/clevermate-deploy/clevermate-forest-v2/node_modules/@forestadmin/agent/src/routes/system/logger.ts:20:7)
at async bodyParser (/home/adel/clevermate/clevermate-deploy/clevermate-forest-v2/node_modules/koa-bodyparser/index.js:78:5)
===================================
Expected behavior
fill the value of field “WP objet” while changing “Nouveau status”
- Project name: clevermate v2
- Environment name: dev
- Agent technology: (nodejs,
- Agent (forest package) name & version: 1.55.1
- Database type: postgres
- Recent changes made on your end if any: …