Feature(s) impacted
Smart actions
Observed behavior
In the smart action, I have a load hook that populates each field with the record’s current value. This works for all fields except for my one Json field. So I open the smart action to edit a record, all of the fields populate with that record’s current values, except for the Json field, which shows as an empty object.
Expected behavior
The ‘metadata’ Json field shows as an empty object, even though it’s populated with a valid Json value. All of the other fields (InstitutionId, AggScriptName, and ConnectionType) were populated as expected when opening the smart action.
Here are snippets of the code:
function init() {
Liana.collection('ScriptData', {
searchFields: ['id', 'aggrScriptName'],
actions: [{
name: 'Edit Script Data',
type: 'single',
fields: getFields(),
hooks: {
load: getValues
}
},
getFields:
function getFields() {
return [
{
field: 'InstitutionId',
reference: 'Institution.InstitutionId',
isRequired: true,
type: 'Number'
},
{
field: 'aggrScriptName',
type: 'String',
isRequired: false
},
{
field: 'connectionType',
type: 'String',
isRequired: false,
},
{
field: 'metadata',
type: 'Json',
isRequired: false,
},
{
field: 'mfaBypassMethod',
type: 'Enum',
enums: ['Q & A',
'OTP',
'Q & A and OTP',
'Captcha Code',
'OTP and Captcha Image',
'Captcha Image',
'Image Selection',
'No MFA'],
isRequired: false,
}, {
field: 'dataSource',
type: 'Enum',
enums: ['QFX',
'OFX',
'CSV',
'QBO'],
isRequired: false,
},]
}
getValues:
async function getValues(context) {
const id = context.request.body.data.attributes.ids[0];
const record = // get script data record
const fields = context.fields;
const mappedFields = new Map();
fields.map(field => {
mappedFields.set(field.field, field)
});
mappedFields.get('InstitutionId').value = record.InstitutionId;
mappedFields.get('aggrScriptName').value = record.aggrScriptName;
mappedFields.get('connectionType').value = record.connectionType;
mappedFields.get('metadata').value = record.metadata;
mappedFields.get('mfaBypassMethod').value = record.mfaBypassMethod;
mappedFields.get('dataSource').value = record.dataSource;
return Array.from(mappedFields.values());
}
The array that gets returned from the above getValues method is as follows:
[
{
field: 'InstitutionId',
reference: 'Institution.InstitutionId',
isRequired: true,
type: 'Number',
position: 0,
defaultValue: null,
description: null,
enums: null,
widget: null,
value: 171151
},
{
field: 'aggrScriptName',
type: 'String',
isRequired: false,
position: 1,
defaultValue: null,
description: null,
reference: null,
enums: null,
widget: null,
value: 'test.scr'
},
{
field: 'connectionType',
type: 'String',
isRequired: false,
position: 2,
defaultValue: null,
description: null,
reference: null,
enums: null,
widget: null,
value: 'PUPPETMASTER'
},
{
field: 'metadata',
type: 'Json',
isRequired: false,
position: 3,
defaultValue: null,
description: null,
reference: null,
enums: null,
widget: null,
value: { name: 'name', keyId: '123', value: 'metadata' }
},
{
field: 'mfaBypassMethod',
type: 'Enum',
enums: [
'Q & A',
'OTP',
'Q & A and OTP',
'Captcha Code',
'OTP and Captcha Image',
'Captcha Image',
'Image Selection',
'No MFA'
],
isRequired: false,
position: 4,
defaultValue: null,
description: null,
reference: null,
widget: null,
value: null
},
{
field: 'dataSource',
type: 'Enum',
enums: [ 'QFX', 'OFX', 'CSV', 'QBO' ],
isRequired: false,
position: 5,
defaultValue: null,
description: null,
reference: null,
widget: null,
value: null
}
]
Failure Logs
No errors in the logs.
Context
- Project name: Woodpecker
- Team name: Connect Services
- Environment name: All environments
- Agent (forest package) name & version: “forest-express”: “^10.1.9”,
“forest-express-sequelize”: “^9.0.5”, - Database type: mySql
- Recent changes made on your end if any: No changes to this smart action in a long time