Mshei
Mshei

Reputation: 29

Finding Values from a form control Outside Forms

i was wondering if it is possible to get the values from my form controls. Through x++ code from my class or my table method ?

I am iterating through my form, and i want to get all the names and values. I got the names but not values, please help thanks.

if (_formControlId)
{
    formGroupControl = _formRun.design().control(_formControlId);
}
else
{
    formGroupControl = _formRun.design();
}
// Finding children
controlCount = formGroupControl.controlCount();
for (i = 1; i <= controlCount; i++)
{
    formControl = formGroupControl.controlNum(i);
    // Fill MainTable
    if(formControl is formTabPageControl)
    {
        if(formControl.HierarchyParent()    == formControl.HierarchyParent("TabHeader"))
        {
            mainTopicId++;
            GloDataMainTopics.Topic     = formControl.labeltext();
            GloDataMainTopics.TopicId   = int2str(mainTopicId);
            GloDataMainTopics.insert();

            newParentTopicId = GloDataMainTopics.TopicId;
        }
    }
    // Fill SubTable
    if(formControl is formGroupControl)
    {
        newParentTopicId = this.fillGroupControls(formControl, _parentTopicId);
    }
    if (!newParentTopicId)
        newParentTopicId = _parentTopicId;
    //Fill Lines
    if (formControl is FormStringControl    || formControl is FormReferenceGroupControl ||
        formControl is FormCheckBoxControl  || formControl is FormComboBoxControl       ||
        formControl is FormWindowControl    || formControl is FormDateControl           ||
        formControl is FormRealControl      || formControl is FormIntControl)
        {
            this.fillLineFields(formControl, newParentTopicId, j);

            /*
            this.fillTabPagePurchase(formControl, newParentTopicId);
            this.fillTabPageGeneral(formControl, newParentRecId);
            */
            //info(strFmt("MainTopics '%1', %2", formControl.name(), j ));
        }

    if (formControl.isContainer())
    {
        this.findNodes(_formRun, formControl.id(), newParentTopicId);
    }
}

Upvotes: 0

Views: 5260

Answers (1)

Alex Kwitny
Alex Kwitny

Reputation: 11544

Yes you can. Bear in mind that some control's values are stored in .text(), valueStr(), etc and not in .value() but you'll figure it out.

Object      control;
control = formControl; // I'm assuming this is your control you're using

if (SysTest::hasMethod(control, identifierStr(text)))
{
    text = control.text();
    info(strFmt("Text found is '%1'", text));
}

if (SysTest::hasMethod(control, identifierStr(value)))
{
    value = control.value();
    info(strFmt("Value found is '%1'", value));
}

Here is a blog post I did that shows how to recurse over all of the form's controls. You can take the inner-method and put it on the form's method, then call it at run-time and just add the extra SysTest:: blocks and it should give you a quick working proof of concept of every control on the form and value/text/etc.

http://www.alexondax.com/2014/05/how-to-use-recursion-to-loop-over-form.html

Upvotes: 1

Related Questions