# Field defaults are not set after approving smart action, but are set as expected when no approval is required

**URL:** https://community.forestadmin.com/t/field-defaults-are-not-set-after-approving-smart-action-but-are-set-as-expected-when-no-approval-is-required/5110
**Category:** Help me!
**Created:** [August 18, 2022, 10:52pm UTC](https://community.forestadmin.com/t/field-defaults-are-not-set-after-approving-smart-action-but-are-set-as-expected-when-no-approval-is-required/5110 "2022-08-18T22:52:51Z")
**Posts on this page:** 8
**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: [August 18, 2022, 10:52pm UTC](https://community.forestadmin.com/t/field-defaults-are-not-set-after-approving-smart-action-but-are-set-as-expected-when-no-approval-is-required/5110/1 "2022-08-18T22:52:51Z")

</div>

## Feature(s) impacted

Smart actions, approval process

## Observed behavior

In our smart action, there are several fields that are not required but have default values set in the database. **When completing the smart action normally, this works as expected** , i.e. we just have to fill out the smart action’s required fields, and then after completing the smart action, the non-required fields that we left blank are properly set to their expected default values.

However, if that same smart action requires an approval, the default values for those non-required fields do not get set after the action is approved.

## Expected behavior

We would expect that the record get created the same way whether it required an approval or not.  
We expect leaving non-required fields blank to get set to their assigned default value when an action needs approval.

## Failure Logs

None

For example, in this screenshot of approval details, the fields accountOwner, ach, aha, and availBalance should default to false but you can see their value is blank.

 ![Screen Shot 2022-08-18 at 4.48.54 PM](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/c/c4fa76bd382569f6ad72b335e76ca48bc8abf509.png)

Also as you can see, the first institution was created with approval required on the smart action, and the second institution was created without approval required on the smart action.  
The fields voa, voi, ach, and rssd are not required to be filled out in the smart action and have defaults set in the db.

 ![Screen Shot 2022-08-18 at 4.54.23 PM](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/8/832ac35b7ce3b6fb3d3f551b7e78b61cbf2d8322.png)

## Context

- Project name: Woodpecker
- Team name: Developers (but happens in all teams)
- Environment name: Testing\_v2 (but happens in all envs)
- Agent type & version: “forest-express”: “^9.4.4”,

```javascript
    "meta": {
        "liana": "forest-express-sequelize",
        "liana_version": "8.5.4",
        "stack": {
          "database_type": "mysql",
          "engine": "nodejs",
          "engine_version": "16.15.1",
          "orm_version": "6.19.0"
        }
      }

```

- Recent changes made on your end if any: None relating to these fields or action

---

<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: [August 19, 2022, 1:17pm UTC](https://community.forestadmin.com/t/field-defaults-are-not-set-after-approving-smart-action-but-are-set-as-expected-when-no-approval-is-required/5110/3 "2022-08-19T13:17:01Z")

</div>

Hi @rachelburnett,

> - Recent changes made on your end if any: None relating to these fields or action

Was this working before ? 🤔

Could you please share your smart action definitions (with all the fields and defaultValue) please 🙏 ?

---

<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: [August 19, 2022, 3:51pm UTC](https://community.forestadmin.com/t/field-defaults-are-not-set-after-approving-smart-action-but-are-set-as-expected-when-no-approval-is-required/5110/4 "2022-08-19T15:51:14Z")

</div>

It looks like this was not working before, we have just noticed it as we’re moving towards all smart actions requiring the approval process. (But again, the smart action without approval works as expected).

from institutions.forest.js

```javascript
function init() {
    Liana.collection("Institution", {
      searchFields: ["id", "name"],
      actions: [
        {
          name: "Create Institution",
          type: "global",
          fields: [
            {
              field: "id",
              type: "Number",
              isRequired: true,
            },
            {
              field: "name",
              type: "String",
              isRequired: true,
            },
            {
              field: "rssd",
              type: "Number",
              isRequired: false,
            },
            {
              field: "rank",
              type: "Number",
              isRequired: false,
            },
            {
              field: "depositShare",
              type: "Number",
              isRequired: false,
            },
            {
              field: "voa",
              type: "Boolean",
              isRequired: false,
            },
            {
              field: "voi",
              type: "Boolean",
              isRequired: false,
            },
            {
              field: "stateAgg",
              type: "Boolean",
              isRequired: false,
            },
            {
              field: "ach",
              type: "Boolean",
              isRequired: false,
            },
            {
              field: "transAgg",
              type: "Boolean",
              isRequired: false,
            },
            {
              field: "aha",
              type: "Boolean",
              isRequired: false,
            },
            {
              field: "availBalance",
              type: "Boolean",
              isRequired: false,
            },
            {
              field: "accountOwner",
              type: "Boolean",
              isRequired: false,
            },
            {
              field: "loanPaymentDetails",
              type: "Boolean",
              isRequired: false,
            },
            {
              field: "studentLoanData",
              type: "Boolean",
              isRequired: false,
            },
            {
              field: "accountTypeDescription",
              type: "String",
              isRequired: false,
            },
            {
              field: "phone",
              type: "String",
              isRequired: false,
            },
            {
              field: "urlHomeApp",
              type: "String",
              isRequired: false,
            },
            {
              field: "urlLogonApp",
              type: "String",
              isRequired: false,
            },
            {
              field: "oauthEnabled",
              type: "Boolean",
              isRequired: true,
            },
            {
              field: "urlForgotPassword",
              type: "String",
              isRequired: false,
            },
            {
              field: "urlOnlineRegistration",
              type: "String",
              isRequired: false,
            },
            {
              field: "class",
              type: "String",
              isRequired: false,
            },
            {
              field: "specialText",
              type: "String",
              isRequired: false,
            },
            {
              field: "specialInstructions",
              type: "Json",
              isRequired: false,
            },
            {
              field: "specialInstructionsTitle",
              type: "String",
              isRequired: false,
            },
            {
              field: "address",
              type: "Json",
              isRequired: false,
            },
            {
              field: "currency",
              type: "Enum",
              enums: ["USD", "AUD", "CAD", "BRL"],
              isRequired: true,
            },
            {
              field: "email",
              type: "String",
              isRequired: false,
            },
            {
              field: "active",
              type: "Boolean",
              isRequired: false,
            },
            {
              field: "status",
              type: "Enum",
              enums: [
                "online",
                "offline",
                "maintenance",
                "testing",
                "investigating",
              ],
              isRequired: true,
            },
            {
              field: "topInstitution",
              type: "Boolean",
              isRequired: true,
            },
            {
              field: "newInstitutionId",
              type: "Number",
              isRequired: false,
            },
            {
              field: "autoMode",
              type: "Boolean",
              isRequired: true,
            },
            {
              field: "accuity_data_id",
              type: "Number",
              isRequired: false,
            },
            {
              field: "showAccountSelectionOAuth",
              type: "Boolean",
              isRequired: false,
            },
            {
              field: "timeZone",
              type: "Enum",
              enums: Object.values(validTimeZones),
              isRequired: false,
            },
            {
              field: "displayName",
              type: "String",
              isRequired: false,
            },
            {
              field: "script data",
              reference: "ScriptData.id",
              isRequired: false,
            },
            {
              field: "account support",
              reference: "AccountSupport.id",
              isRequired: false,
            },
            {
              field: "branding",
              reference: "branding.id",
              isRequired: false,
            },
            {
              field: "country code",
              reference: "CountryCodeReference.institutionId",
              isRequired: true,
            },
          ],
        },
      ],
    });
  }

```

And from our institution model

```javascript
const Institution = sequelize.define('Institution', {
    'id': {
      primaryKey: true,
      allowNull: false,
      type: DataTypes.INTEGER,
      unique: true
    },
    'name': {
      type: DataTypes.STRING
    },
    'rssd': {
      type: DataTypes.INTEGER,
      allowNull: true,
      defaultValue: -1
    },
    'rank': {
      type: DataTypes.INTEGER,
      allowNull: true
    },
    'depositShare': {
      type: DataTypes.FLOAT,
      allowNull: true
    },
    'voa': {
      type: DataTypes.BOOLEAN,
      defaultValue: false
    },
    'voi': {
      type: DataTypes.BOOLEAN,
      defaultValue: false
    },
    'stateAgg': {
      type: DataTypes.BOOLEAN,
      defaultValue: false
    },
    'ach': {
      type: DataTypes.BOOLEAN,
      defaultValue: false
    },
    'transAgg': {
      type: DataTypes.BOOLEAN,
      defaultValue: true
    },
    'aha': {
      type: DataTypes.BOOLEAN,
      defaultValue: false
    },
    'availBalance': {
      type: DataTypes.BOOLEAN,
      defaultValue: false
    },
    'accountOwner': {
      type: DataTypes.BOOLEAN,
      defaultValue: false
    },
    'loanPaymentDetails': {
      type: DataTypes.BOOLEAN,
      defaultValue: false
    },
    'studentLoanData': {
      type: DataTypes.BOOLEAN,
      defaultValue: false
    },
    'accountTypeDescription': {
      type: DataTypes.STRING
    },
    'phone': {
      type: DataTypes.STRING
    },
    'urlHomeApp': {
      type: DataTypes.STRING(1150)
    },
    'urlLogonApp': {
      type: DataTypes.STRING(1150)
    },
    'oauthEnabled': {
      type: DataTypes.BOOLEAN,
      defaultValue: false,
      allowNull: false
    },
    'urlForgotPassword': {
      type: DataTypes.STRING(1150)
    },
    'urlOnlineRegistration': {
      type: DataTypes.STRING(1150)
    },
    'class': {
      type: DataTypes.STRING
    },
    'specialText': {
      type: DataTypes.STRING
    },
    'timeZone': {
      type: DataTypes.ENUM(Object.values(validTimeZones)),
      allowNull: true
    },
    'specialInstructions': {
      type: DataTypes.JSON,
      validate: {
        isValidSpecialInstruction(value) {
          const result = specialInstructionSchema.validate(value);
          if (result.error) {
            throw new Error('Special Instructions is not formatted correctly');
          }
        }
      }
    },
    'specialInstructionsTitle': {
      type: DataTypes.STRING,
      allowNull: true,
    },
    'address': {
      type: DataTypes.JSON,
      validate: {
        isValidAddress(value) {
          const result = addressSchema.validate(value);
          if (result.error) {
            throw new Error('Address is not formatted correctly');
          }
        }
      }
    },
    'currency': {
      type: DataTypes.STRING,
      defaultValue: 'USD',
      allowNull: false
    },
    'email': {
      type: DataTypes.STRING
    },
    'active': {
      type: DataTypes.BOOLEAN,
      defaultValue: false
    },
    'status': {
      type: DataTypes.STRING,
      allowNull: false,
      defaultValue: 'online',
      validate: {
        isIn: [['online', 'offline', 'maintenance', 'testing', 'investigating']],
      }
    },
    'overallStatusTemp': {
      type: DataTypes.STRING,
      allowNull: false,
      defaultValue: 'online',
      validate: {
        isIn: [['online', 'offline', 'maintenance', 'testing', 'investigating']],
      }
    },
    'transAgg_status': {
      type: DataTypes.ENUM(...STATUS_OPTIONS),
      allowNull: true,
    },
    'voa_status': {
      type: DataTypes.ENUM(...STATUS_OPTIONS),
      allowNull: true,
    },
    'voi_status': {
      type: DataTypes.ENUM(...STATUS_OPTIONS),
      allowNull: true,
    },
    'stateAgg_status': {
      type: DataTypes.ENUM(...STATUS_OPTIONS),
      allowNull: true,
    },
    'accountOwner_status': {
      type: DataTypes.ENUM(...STATUS_OPTIONS),
      allowNull: true,
    },
    'ach_status': {
      type: DataTypes.ENUM(...STATUS_OPTIONS),
      allowNull: true,
    },
    'aha_status': {
      type: DataTypes.ENUM(...STATUS_OPTIONS),
      allowNull: true,
    },
    'availBalance_status': {
      type: DataTypes.ENUM(...STATUS_OPTIONS),
      allowNull: true,
    },
    'topInstitution': {
      type: DataTypes.BOOLEAN,
      defaultValue: false,
      allowNull: false
    },
    'checkImage': {
      type: DataTypes.BOOLEAN,
      defaultValue: false
    },
    'newInstitutionId': {
      type: DataTypes.INTEGER,
      allowNull: true
    },
    'requiresFinicityCallout': {
      type: DataTypes.BOOLEAN,
      defaultValue: false,
      allowNull: false
    },
    'autoMode': {
      type: DataTypes.BOOLEAN,
      defaultValue: true,
      allowNull: false
    },
    'accuityData': {
      type: DataTypes.STRING,
      allowNull: true,
    },
    'showAccountSelectionOAuth': {
      type: DataTypes.BOOLEAN,
      defaultValue: false
    },
    'statusCode': {
      type: DataTypes.STRING,
      defaultValue: false,
      allowNull: true
    }, 
    'externalId':{
      type: DataTypes.STRING,
      defaultValue: null,
      allowNull:true
    },
    'displayName': {
      type: DataTypes.STRING,
      allowNull: true
    }
  },
  {
    tableName: 'institutions',
    timestamps: true,
    createdAt: 'createdAt',
    updatedAt: 'updatedAt'
  }
  );

```

---

<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: [August 22, 2022, 3:25pm UTC](https://community.forestadmin.com/t/field-defaults-are-not-set-after-approving-smart-action-but-are-set-as-expected-when-no-approval-is-required/5110/5 "2022-08-22T15:25:44Z")

</div>

Oh okey the `defaultValue `are inside your model not your smart action 🤔.  
I see where is the difference, when doing a smart action without approval, only the field that are filled are sent while in the approval, everything is sent.

I will create a bug ticket: [ClickUp](https://sharing.clickup.com/2453539/t/h/2v72fmg/R38SGEIRWR6RO5R)

---

<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: [August 22, 2022, 4:36pm UTC](https://community.forestadmin.com/t/field-defaults-are-not-set-after-approving-smart-action-but-are-set-as-expected-when-no-approval-is-required/5110/6 "2022-08-22T16:36:37Z")

</div>

I see, thank you very much!

Do you have an estimate for when the fix will be released?

---

<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: [August 24, 2022, 9:43pm UTC](https://community.forestadmin.com/t/field-defaults-are-not-set-after-approving-smart-action-but-are-set-as-expected-when-no-approval-is-required/5110/7 "2022-08-24T21:43:29Z")

</div>

@anon62739609 Any update on when this will be fixed?

---

<div class="post-metadata">

### Author: ![anon34731316](https://avatars.discourse-cdn.com/v4/letter/a/eada6e/32.png) [@anon34731316](https://community.forestadmin.com/u/anon34731316)
#### Post date: [August 31, 2022, 12:20pm UTC](https://community.forestadmin.com/t/field-defaults-are-not-set-after-approving-smart-action-but-are-set-as-expected-when-no-approval-is-required/5110/8 "2022-08-31T12:20:52Z")

</div>

Hello @rachelburnett,  
A fix has been released, could you please tell me if everything is working as expected on your side?  
Thanks!

---

<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: [August 31, 2022, 8:17pm UTC](https://community.forestadmin.com/t/field-defaults-are-not-set-after-approving-smart-action-but-are-set-as-expected-when-no-approval-is-required/5110/9 "2022-08-31T20:17:40Z")

</div>

Hi @anon34731316, yes this is now working as expected. Thank you!
