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 :
Microsoft Dynamics AX (Archived)

form not initializing from INFO class startupPost method x++

(0) ShareShare
ReportReport
Posted on by

Hi there,

I have a form, let's say, HBDayForm. The purpose of this is to greet the user with a messaje if it's his birthday.

The form is ok, it' s functional and tested. The problem is that the only viable solution I found is to modify the startupPost method from the info class, in order to 'trigger the form'.
 I went to the EmplTable and I modified my BDay to match the current date , however, the form is not initialized when AX starts. 

Any Idea why the form is not triggered or if there is any other method than startupPost to be modified?
Many thanks!
Version: AX 2009
Code:

void startupPost()
{

EmplTable emplTable;
int dayOfBirth = dayOfMth(emplTable.BirthDate);
int monthOfBirth = mthOfYr(emplTable.BirthDate);
int dayOfMonth = dayOfMth(systemdateget());
int monthOfYear = mthOfYr(systemdateget());
str emplName = emplTable.name();
Args args = new Args(); //formrun
FormRun formrun;

;

if (dayOfBirth == dayOfMonth && monthOfBirth == monthOfyear )
{
args.name(formStr(HBDayForm));
formRun = classFactory.formRunClass(args);
formRun.init();
formrun.run();
}

}

*This post is locked for comments

I have the same question (0)
  • Community Member Profile Picture
    on at

    Thank you John! :)

  • Verified answer
    Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at

    You forgot to assign a value to your emplTable variable, therefore it will always be empty. You probably want something like this:

    EmplTable emplTable = EmplTable::find(EmplTable::userId2EmplId(curUserId());

    You would have seen the problem very clearly in debugger, if you debugged your code.

  • Community Member Profile Picture
    on at

    Thank you!

  • Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at

    Why don't you use the debugger to see what exactly is wrong with your condition? There is no need to wonder and guess, if you can easily see which values are in which variable. Then you'll know exactly what to fix.

    I already gave you the method that uses the link between employees and users (EmplTable::userId2EmplId()), so why don't you simply look inside? It's just normal X++ code that you can see (either in debugger or in code editor).

  • Community Member Profile Picture
    on at

    Hi Martin,

    Unfortunately, I'm working on a training machine and my debugger was not activated by my sys admin. And I don't think I'll find someone to activate it today.

    Already tried the steps from this page but I don't have admin right on my VM:

    msdn.microsoft.com/.../aa629010.aspx

    Thanks for all the help provided!

  • Community Member Profile Picture
    on at

    Also, I think the problem is in the fact that my EmplId is an int of 5 characters and the UserId is a string of 5.

  • Community Member Profile Picture
    on at

    this is the error i receive:

    www.dropbox.com/.../operandtypes%20error.JPG

  • Verified answer
    Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at

    Debugging is a half of programming, so if you want to do development, you need a proper development environment. I'm sure that your employer don't want you wasting large amount of time without any reason.

    What problem are you talking about when saying "the problem is in the fact that my EmplId is an int of 5 characters">? You've never mentioned that, not even in your reply that you've deleted for some reason (which is what I reacted to above).

    Regarding the error message, ideally put it here as text, because than it can be indexed by search engines. If you want to use an image, please insert it directly into your post (don't forget to switch to rich formatting to see the option).

  • Community Member Profile Picture
    on at

    Understood. I edited that comment because I though I replied wrong. Sorry. It's possible I'll do a few annoying mistakes for a few days\weeks. :)

    error message:

    "Operand types are not compatible with the operator."

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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans