web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Running Form from Code doesn't function correctly

(0) ShareShare
ReportReport
Posted on by 3,155

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.

I have the same question (0)
  • Suggested answer
    b_radlyjames Profile Picture
    3,155 on at

    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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 664 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 522 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 303 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans