AX2012:Restore or (Ctrl + F5) command on forms using X++ code

Hi Friends,
This is a simple tip but good to keep the information handy.
When the records displayed on the form are updated by some other process we get an error \”The values displayed in the form are not current, so an update or deletion cannot be made. To view the current values, on the Command menu, click Restore or press CTRL+F5\”.

In one of my recent projects, there was a situation when I wanted execute ctrl+ F5 command from code. I looked into the task macro but this command was not defined there so the challenge was to find the task id for this command so that I can pass it in element.task() method.

In order to get this task ID, I override the task method on the form and enabled debugger, opened the form and pressed ctrl + F5. The method was called and I got the task ID as 2839.

So in order to execute ctrl+F5 just call element.task(2839) and the record values will be restored.

You can also find task ID of other commands using this approach.

Thanks for reading the blog.
Keep sharing.

3 Replies to “AX2012:Restore or (Ctrl + F5) command on forms using X++ code”

  1. Celeste says:

    This is not the right approach. The reason for the “values displayed in the form are not current..” error is because of fields that are updated in the datasource’s active() method.If you force an element refresh, the data is read from the table again and any changes made by the user is lost.The best way to fix this is to remove the code that update the field values in the active method of the datasource.

    Like

  2. Rachit Garg says:

    Thanks Celeste. Appreciate your feedback. My main intention is to show how we can track the task ID of any specific event. I agree we should not ignore of try to supress this message. Regards,Rachit Garg

    Like

  3. Roger says:

    2875 in ax 2012

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

A WordPress.com Website.
%d bloggers like this: