# Json field not populating in smart action

**URL:** <https://community.forestadmin.com/t/json-field-not-populating-in-smart-action/6804>\
**Category:** Help me!\
**Created:** [November 1, 2023, 10:54pm UTC](https://community.forestadmin.com/t/json-field-not-populating-in-smart-action/6804 "2023-11-01T22:54:34Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![rachelburnett](https://avatars.discourse-cdn.com/v4/letter/r/cc9497/32.png) [@rachelburnett](https://community.forestadmin.com/u/rachelburnett)\
**Post date:** [November 1, 2023, 10:54pm UTC](https://community.forestadmin.com/t/json-field-not-populating-in-smart-action/6804/1 "2023-11-01T22:54:34Z")

</div>

## 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.

 ![Screen Shot 2023-11-01 at 4.31.21 PM](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/7/7a358d248ff4a8e1dfd09b84178c377eb52d9697.png)

Here are snippets of the code:

```javascript
function init() {
    Liana.collection('ScriptData', {
      searchFields: ['id', 'aggrScriptName'],
      actions: [{
        name: 'Edit Script Data',
        type: 'single',
        fields: getFields(),
        hooks: {
          load: getValues
        }
      },

```

getFields:

```javascript
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:

```javascript
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:

```javascript
[
  {
    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

---

<div class="post-metadata">

**Author:** ![nbouliol](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/nbouliol/32/5777_2.png) [@nbouliol](https://community.forestadmin.com/u/nbouliol)\
**Post date:** [November 2, 2023, 11:46am UTC](https://community.forestadmin.com/t/json-field-not-populating-in-smart-action/6804/2 "2023-11-02T11:46:48Z")

</div>

Hello @rachelburnett

I can reproduce your bug on my end.  
I will create a ticket and we’ll let you know when the bug is fixed.

Regards,  
Nicolas

---

<div class="post-metadata">

**Author:** ![nbouliol](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/nbouliol/32/5777_2.png) [@nbouliol](https://community.forestadmin.com/u/nbouliol)\
**Post date:** [November 2, 2023, 1:36pm UTC](https://community.forestadmin.com/t/json-field-not-populating-in-smart-action/6804/3 "2023-11-02T13:36:39Z")

</div>

@rachelburnett

Does this look like a Forest regression to you ?

Do you remember when you noticed the bug ?

---

<div class="post-metadata">

**Author:** ![rachelburnett](https://avatars.discourse-cdn.com/v4/letter/r/cc9497/32.png) [@rachelburnett](https://community.forestadmin.com/u/rachelburnett)\
**Post date:** [November 2, 2023, 4:15pm UTC](https://community.forestadmin.com/t/json-field-not-populating-in-smart-action/6804/4 "2023-11-02T16:15:22Z")

</div>

Hi, thank you @nbouliol!

Do you have a rough estimate on when the bug will be fixed?

We started seeing this bug on October 16th.

---

<div class="post-metadata">

**Author:** ![nbouliol](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/nbouliol/32/5777_2.png) [@nbouliol](https://community.forestadmin.com/u/nbouliol)\
**Post date:** [November 3, 2023, 9:00am UTC](https://community.forestadmin.com/t/json-field-not-populating-in-smart-action/6804/5 "2023-11-03T09:00:32Z")

</div>

Hello @rachelburnett

Thank you for the feedback.

I cannot give you an estimation, but it’s on our top priorities

---

<div class="post-metadata">

**Author:** ![anon62739609](https://avatars.discourse-cdn.com/v4/letter/a/c2a13f/32.png) [@anon62739609](https://community.forestadmin.com/u/anon62739609)\
**Post date:** [November 7, 2023, 2:13pm UTC](https://community.forestadmin.com/t/json-field-not-populating-in-smart-action/6804/6 "2023-11-07T14:13:59Z")

</div>

Hey @rachelburnett,

A fix has been merged this morning. Could you retry and let us know if it works on your side 👼 ?

---

<div class="post-metadata">

**Author:** ![rachelburnett](https://avatars.discourse-cdn.com/v4/letter/r/cc9497/32.png) [@rachelburnett](https://community.forestadmin.com/u/rachelburnett)\
**Post date:** [November 7, 2023, 4:52pm UTC](https://community.forestadmin.com/t/json-field-not-populating-in-smart-action/6804/7 "2023-11-07T16:52:43Z")

</div>

It is working, thank you very much!
