Developer forum

Forum » Dynamicweb 9.0 Upgrade issues » GetString("Item.Page.[FieldSystemName]") does not return any value

GetString("Item.Page.[FieldSystemName]") does not return any value

Lars Larsen
Lars Larsen
Reply

Hi

I am running DW9.1.4 and have an itemtype for page properties which I have attached to the website. The itemtype has a field of type checkbox and the fields default value is "True". Now from my master template I wants to get the value from this field. I use @GetString("Item.Page.MyCheckBoxFieldSystemName"). But no value is rendered in the frontend. Is this a bug?

BTW how do I get the page properties field value through the API?


Replies

 
Nicolai Pedersen
Reply

Take a look at @TemplateTags() and see if you got it spelled correctly and has a value.

Or try using GetBoolean instead of GetString.

BR Nicolai

 
Lars Larsen
Lars Larsen
Reply

Hi Nicolai

It's a bit weird. Because @TemplateTags() does not output my tag (I have double checked the spelling). GetBoolean() returns correctly the value, but GetString() and GetValue() does not! Shouldn't these to functions work too?

Anyway thanks for your tip smiley

 
Lars Larsen
Lars Larsen
Reply

Hi Nicolai

Now I figured it out. I have added this page properties itemtype with one field with the default value "True". But this value is not stored in the database until you save the page, even though the value shows up (as a checked checkbox) when you edit a page and looks at its properties. Now when using GetString() and GetValue() there is no value to return because the default value is not saved in the database, but GetBoolean() returns "False", because the boolean value is not set (its actually null).

Lesson to learn: Always use GetString(), GetBoolean(), GetInteger() etc. according to the datatype of the returned field

 

You must be logged in to post in the forum