Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

Full path to form control

Posted on by 25

Hello, everybody

I have a form 

form = new Form(utilElements.name);

design 

designObj = form.design();

form control
if (_formControlId)
{
    formGroupControl = form.design().control(_formControlId);
}
else
{
    formGroupControl = form.design();
}

controlCount            = formGroupControl.controlCount();

for (idx = 1; idx <= controlCount; idx++)
{
    formControl = formGroupControl.controlNum(idx);
}

How can I get full path to form control like (@"\Forms\HRMEmplMultiJournalTable\Designs\Design\[Tab:Tab]\[TabPage:HistoryTab]\[Group:History]\DateEdit:History_createdDate)?

*This post is locked for comments

  • epihodi Profile Picture
    epihodi 25 on at
    RE: Full path to form control

    Most likely I will do as you advise. I understand why I get an error. While the form is not initialized, search by control code is not possible. Not all forms can be initialized from code, because the init method before super() can be the following code

    if (!element.args().caller())    
    {
        throw error(Error::missingParameter(null));
    }

    To solve this problem, I spent 5 hours)

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: Full path to form control

    What do you have in formRun and _id variables?

    Also are you sure it's less work to fight with this code instead of navigating to the controls in the DesignList? After all this is a one time job / upgrade so maybe this small manual extra work is cheaper in the end? And the actual change of the data type is manual anyway. I imagine there's plenty of work to change Dates to DateTime, but this form control change is just a small part of it.

    For example navigating to 100 controls using form name and control name would for sure take less than half an hour of time. How long did you spend solving this problem?

  • epihodi Profile Picture
    epihodi 25 on at
    RE: Full path to form control

    I try to use 

    SysFormRun::ctrlId2treeNodePath(formRun, formControl.id());

    but in method ctrlId2treeNodePath in the line formControl (fc)

    fc  = formRun.control(_id);

    not initialized

    Did anyone have a similar problem?

  • epihodi Profile Picture
    epihodi 25 on at
    RE: Full path to form control

    Yes, I can use only formName and controlName, but it will take a lot of time.

    if I have a full path I can do this ->

    ForumFormControl.jpg

    after double-click will open the form and the DateEdit control will be in focus

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: Full path to form control

    Ok but what do you need the full path for?

    Isn't it enough to know the form name and the control name? You can always find a flat list of all form controls in [Form]\Designs\DesignList. 

  • epihodi Profile Picture
    epihodi 25 on at
    RE: Full path to form control

    We change Axapta version from ax4 to ax2012. In Ax4 we have some forms with DateEdit control, but field type in Table is DateTime. Now I need to find all controls DeteEdit on forms and chenge them to DateTime. I write the job.

    formControlType = SysFormRun::controlType(classidget(formControl));
    
    if (formControlType == FormControlType::Date ||
    
       formControlType == FormControlType::Time)
    
    {
    
       // ret = full path
    
       info(ret, '', SysInfoAction_newWindow::newTreeNodePath(ret));
    
    }


    When doubleClick in info and I can see the control in form

  • nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: Full path to form control

    What do you need it for?

    You can right click a control and select Add-ins - Copy - Entire path.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans