vasanth
I'm new here

How Read the Overridden Variable in Site Store

Dear All,

Is there any way to read the Overridden variable in site store's variable tab ??

Please find the below code which is working for the Declared Variable in Site Store.

reference.getReferencedObject().getParent().getData ().get("ss_XXXXX");

Thank You,

Vasanth.

1 Reply
gockel
Crownpeak employee

Hi,

I'm not sure if I really understand your problem.

Let's assume we have a variable structure like this:

variables.jpg

Starting with an API context on element 'level 2' (e.g. a context menu script), following some simple source code examples, that may help you.

level2;     // node context

english = context.getProject().getLanguage("EN");

varFormData = level2.getFormData();

fieldOne = varFormData.get(english, "mySecondVariable");

fieldOne.get();

<overwritten value in level 2>

// throws NoSuchFormFieldException because variable 'myVariable' is not defined in node 'level 2' -> value is inherited

varFormData.get(english, "myVariable");    

// get a list of valid field names (in this case names of variables defined in this formData)

fieldNames = varFormData.getForm().appendEditorNames(null);

// check wether a specific variable is declared in this formdata

GomFormElement editor = varFormData.getForm().findEditor("mySecondVariable");

print(editor != null);

<true>

editor = varFormData.getForm().findEditor("myVariable");

print(editor != null);

<false>

parentFormData = level2.getParent().getFormData();

editor = parentFormData.getForm().findEditor("myVariable");

print(editor != null);

<true>

if (editor != null) {

     field = parentFormData.get(english, editor.getName().toString());

     field.get();

     <overwritten value in level 1>

}