Delegated Admin Extension: custom property not writing to app_metadata

I have the following Settings Query configured for my Delegated Admin Extension dashboard to try and configure the user’s app_metadata.city property:

function(ctx, callback) {
  return callback(null, {
    connections: [ctx.request.user.identities[0].connection],
    dict: {
      title: ctx.request.user.identities[0].connection ? ctx.request.user.identities[0].connection + ' Management' : 'User Management Dashboard',
      menuName: ctx.request.user.name
    },
    userFields: [
        {
            "property": "app_metadata.city",
            "label": "City",
			"create": {
                "required": true,
                "type": "select",
				"component": "InputMultiCombo",
				"options": Array("Paris", "New York")
            },
			"edit": {
                "required": true,
                "type": "select",
				"component": "InputMultiCombo",
				"options": Array("Paris", "New York")
            }
        },
		{
            "property": "repeatPassword",
			"create": false,
			"edit": false
        }
    ]
  });
}

However when creating a new user and choosing the city field the value is not added to the users app_metadata.city.

What am I doing wrong?

Well found the solution eventually, it had to be included in a Write Hook, something like this:

function(ctx, callback) {
  var newProfile = {
    email: ctx.payload.email,
    password: ctx.payload.password,
    connection: ctx.payload.connection,
    app_metadata: {
      city: ctx.payload.city
    }
  };
  
  return callback(null, newProfile);
}

I also changed the property name to “city” in the Settings Query instead of the previous “app_metadata.city”.

1 Like

Thanks for sharing that with the rest of community!