Developer forum

Forum » Development » Change field properties using API

Change field properties using API

Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi guys,

I have a situation where I need to set some properties of the field using the API.
And by properties I mean mostly Required, Hidden and ReadOnly.

I know that some of these properties are not stored in the database but rather in the GlobalSettings.

Can I adjust the value of these properties using the API?

Is there any other way to attach custom properties to fields (ProductFields, GroupFields or ProductCategoryFields)?

Thank you,

Adrian


Replies

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi guys,

Anybody?

Thank you,

Adrian

 
Morten Snedker Dynamicweb Employee
Morten Snedker
Reply

Hi Adrian,

The mentioned properties are not setable on the field object themselves. Ordinary product fields do have IsRequired/IsReadOnly/IsHidden, but the values are not setable.

So you need to set through GlobalSettings. In this example I have a product field named "Measure", where Required is set to True:

Dynamicweb.Configuration.SystemConfiguration.Instance.SetValue("/Globalsettings/Settings/Ecom/Required/ProductFields/Measure", "True");

BR
Snedker

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply
This post has been marked as an answer

Hi Morten,
Thank you for the suggestion. As long as I can control it in a programmatic way, I am fine.

Thank you,

Adrian

 

Votes for this answer: 1

 

You must be logged in to post in the forum