Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Suggested answer

Running Form from Code doesn't function correctly

(0) ShareShare
ReportReport
Posted on by 3,061

When running the 'ProjTableCreate' Form from Code, I am not getting the same behavior as if I were to run it from the 'ProjTableCreateSubproject' display menu item.

Code:

ProjTable projTable = ProjTable::find('P400011');
FormRun formRun;
Args args = new Args();
;

args.name(formstr(ProjTableCreate));

args.parmEnumType(enumNum(ProjTableCreateLevel));
args.parmEnum(ProjTableCreateLevel::Subproject);
args.record(ProjTable);

formRun = ClassFactory.formRunClass(args);
formRun.init();
formRun.run();

if (!formRun.closed())
formrun.wait(true);

This results in:

pastedimage1586186321193v2.png

If this were run correctly, it would look like this:

pastedimage1586186397984v3.png

The project ID would show a new Subproject ID rather than just the first project in the Project Table.

In debugging, I can tell that when running through code it is not hitting some of the 'ProjTable' data source methods but I can't figure out why.

EDIT:

I am wanting to run this in code so I can use:

if (!formRun.closed())
formrun.wait(true);

This forces the user to deal with the form that popped up and prevents them from going to other forms.  If there was a way to do this while using the standard menu item, I am fully open to that.

  • Suggested answer
    b_radlyjames Profile Picture
    b_radlyjames 3,061 on at
    RE: Running Form from Code doesn't function correctly

    I found a way around this.

    I made a duplicate of the 'ProjTableCreate' from for use with my new functionality.

    Then set the 'Designs' 'Always on Top' property to 'Yes.

    That did it!

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,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans