Prevent Editing of a Field
Elisa Dinsmore avatar
Written by Elisa Dinsmore
Updated over a week ago

This article is for Flatfile's Portal 2.0. If you'd like to check out the latest version of the Flatfile Data Exchange Platform, click here!

If you have some fields that need to be imported but you don't want the user to edit the field, you can use a Data Hook like this to prevent editing. The following Data Hook is formatted for Portal 2.0.

// container for values of firstName field that shouldn't be edited
let fnameNoEdit = [];
importer.registerRecordHook(async (record, index, mode) => {
let out = {};
// store every value of field as it's loaded into Flatfile and
// show user that it shouldn't be edited
if (record.firstName && mode === "init") {
out.firstName = {
value: record.firstName,
info: [{ message: "This field can not be edited", level: "info" }]
fnameNoEdit[index] = out.firstName;
// If user does change the field, reset the value to what it was
if (record.firstName && mode === "change") {
if (record.firstName !== fnameNoEdit[index].value) {
out.firstName = {
value: fnameNoEdit[index].value,
info: [{ message: "This field can not be edited", level: "warning" }]
return out;
Did this answer your question?