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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

How to pass values through Action Menu Item

(0) ShareShare
ReportReport
Posted on by 42

Hello Dynamics Community,

I am trying to pass value from one class to another using Action Menu Item. Is there any way to achieve that?

For example,

class Class1 extends RunBase
{

AccountNum AccountNum;

#DEFINE.CurrentVersion(1)
#LOCALMACRO.CurrentList
AccountNum
#ENDMACRO

container pack()
{
return [#CurrentVersion,#CurrentList;
}

public boolean unpack(container _packedClass)
{
int version = conPeek(_packedClass,1);
switch (version)
{
case #CurrentVersion:
[version,#CurrentList = _packedClass;
break;
default:
return false;
}
return true;
}

public Object dialog()
{
Dialog dialog = super();
dialog.caption( 'Simple Dialog');
dialog.addMenuItemButton(MenuItemType::Action, 'ActionMenuItem1');
return dialog;
}

public void run()
{
info("Class1");
}

void setValue()
{
AccountNum = '4';
}

public AccountNum getAccountNum()
{
return AccountNum;
}

public static void main(Args _args)
{
Class1 class1 = new Class1();
class1.setValue();

if (class1.prompt())
{
class1.run();
}
}

}

class Class2 extends RunBase
{

    public static void main(Args _args)
    {
        Class1 class1;
        Object caller = _args.caller(); // To get the caller
        class1 = caller.runBase(); // To get object of caller class
        
        Info(strFmt("Value of AccountNum in Class1 : %1", class1.getAccountNum()));
    }

    public void run()
    {
        info("Hello");
    }

}

I have Class1 and Class2 and one Action Menu Item for Class2. Now I am calling the menu item from the dialog method and would like to pass the value(in my case AccountNum) from Class1 to Class2.

Is there any way to achieve that? Please suggest.

I have the same question (0)
  • Dynamics Community 101 Profile Picture
    310 on at

    Dear Sourav,

    This link will help you.

    dynamicscommunity101.blogspot.com/.../how-to-call-menu-item-throught-code-x.html

  • Verified answer
    Sourav Mazumdar Profile Picture
    42 on at

    Thanks Atul for your suggestion!

    After doing some research, I have found solution to my question.

    Since, I was using RunBase framework, I can get my caller's object by _args.caller().runBase().

    Hence, I updated my Class2 main method.

    public static void main(Args _args)
        {
            Class1 class1;
            Object caller = _args.caller(); // To get the caller
            class1 = caller.runBase(); // To get object of caller class
            
            Info(strFmt("Value of AccountNum in Class1 : %1", class1.getAccountNum()));
        }

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 586 Super User 2026 Season 1

#2
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 311

#3
Diego Mancassola Profile Picture

Diego Mancassola 271

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans