Custom field value not being set

Danny Winbourne asked on October 21, 2021 17:54

I've added a new custom field to the Order Address class in the E-commerce Module. We already had 2 other custom fields there.

In code, I am trying to set the value using the below code example:

address.SetValue("AddressCompanyName", DeliveryCompanyNameInput.Value.Trim());

But the "SetValue" method returns false, and value is not set (I try and read back using address.GetValue("AddressCompanyName"), but it returns "null".

For the other custom fields, the "SetValue" method returns "true".

From what I can see, I am doing everything the same as the existing custom fields, but I must have missed something.

I've checked the COM_Address table in the database, and the newly created field doesn't not appear to be added, which is strange.

Any tips are greatly appreciated.

EDIT: The field now appears in the database - HOWEVER - I am still not able to Set the value - (SetValue method returns false).

If I check the .ColumnNames property, it does not contain my new field.

I did a test on the Order Class instead, and the field appeared right away in the table, and also appears in the .ColumnNames property.

Recent Answers


Rui Wang answered on October 21, 2021 19:25

See if you can delete the field in modules and get any errors. If it appears in UI but not in database, something is not right.

0 votesVote for this answer Mark as a Correct answer

Danny Winbourne answered on October 22, 2021 09:15 (last edited on October 22, 2021 09:38)

Edit: This morning, somewhat strangely, I can add the field, and it appears in the database - however, the SetValue method is still returning "false", and value is not being set.

0 votesVote for this answer Mark as a Correct answer

Rui Wang answered on October 22, 2021 16:16 (last edited on October 22, 2021 16:16)

Did you create the other 2 custom fields or someone else did? Can you try change the name of one of those field and see if the code still works? I'm wondering if there is a override class somewhere in the code that maps the custom fields.

0 votesVote for this answer Mark as a Correct answer

Danny Winbourne answered on October 22, 2021 16:20

The existing custom fields existed before I worked on the project. I did search the entire codebase for references to the existing fields, but there is nothing. I am going to ask another Developer to try themselves (we work of our own databases). I've not yet tried renaming an existing field.

0 votesVote for this answer Mark as a Correct answer

Rui Wang answered on October 22, 2021 16:22

maybe one more basic question. Is your code connected to the right database where the new field is been added? since it sounds like you have multiple instances.

0 votesVote for this answer Mark as a Correct answer

Danny Winbourne answered on October 22, 2021 16:26

Yes, 100% same database, as it's all local. I've done tests where I add/remove the field on a different class, whilst doing SQL commands so confirm this.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.