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

Add Range in Controller Class

(0) ShareShare
ReportReport
Posted on by

Hi all,

in my class i want to pass parameter that equal to base enum the string variable of enum

called Action Parameter from main to proprompamodifcontract in my class

to help me in add range to the query 

i used override method new and pass parameter called ActionParm in new and set Super() in it

but the parameter not passed

my proprompamodifcontract  method code is

protected void prePromptModifyContract()
{
Query myQuery;
QueryBuildDataSource QBDS;
//myQuery = this.parmReportContract().parmQueryContracts().lookup(this.getFirstQueryContractKey());
myquery = new Query(querystr (pendingordersquery));
QBDS = myquery.datasourcetable(tablenum(pendingordersview));
if (myQuery)
{
myQuery.dataSourceTable(tableNum(PendingOrdersView)).clearRanges();
if (ActionParm == "0")
{
QBDS.addRange(fieldNum(PendingOrdersView, CustGroup)).value(queryvalue(131));
QBDS.addRange(fieldNum(PendingOrdersView, SalesStatus)).value(queryvalue("Open order" || "Delivered"));
}
else if (ActionParameter == "1")
{
QBDS.addRange(fieldNum(PendingOrdersView, CustGroup)).value("133");
QBDS.addRange(fieldNum(PendingOrdersView, SalesStatus)).value("Open order , Delivered");
}
}
}

*This post is locked for comments

I have the same question (0)
  • Martin Dráb Profile Picture
    239,381 Most Valuable Professional on at

    First of all, let me refactor your code to something more readable:

    protected void prePromptModifyContract()
    {
        Query myQuery = new Query(queryStr(PendingOrdersQuery));
        QueryBuildDataSource qbds = myQuery.datasourceTable(tableNum(PendingOrdersView));
        
        qbds.clearRanges();
        
        if (ActionParm == "0")
        {
            qbds.addRange(fieldNum(PendingOrdersView, CustGroup)).value(queryValue(131));
            qbds.addRange(fieldNum(PendingOrdersView, SalesStatus)).value(queryValue("Open order" || "Delivered"));
        }
        else if (ActionParameter == "1")
        {
            qbds.addRange(fieldNum(PendingOrdersView, CustGroup)).value("133");
            qbds.addRange(fieldNum(PendingOrdersView, SalesStatus)).value("Open order , Delivered");
        }
    }

     

    I see several issues there, but if your main problem is that you don't get the value of ActionParm, this code is not related to your problem. You have to look at code where unsuccessfully try to set the value.

  • Walid Gamal Profile Picture
    on at

    thanks for your replay

    i will sent my code

    this is main

    public static client void main(Args args)

    {

       str ActionParameter =        args.parmEnum();

       PendingOrderController       QOPOG;

       //define the new object for controller class

       QOPOG   = new PendingOrderController(ActionParameter);

       //set the report name and report design to run

       if (ActionParameter == "0")

       {

               QOPOG.parmreportname(ssrsreportstr(PendingOrders, PendingOrdersbyCustomer));

       }

       else if(ActionParameter == "1")

       {

               QOPOG.parmreportname(ssrsreportstr(PendingOrders,PendingOrdersbyCustomer));

       }

       //execute the report

       QOPOG.startoperation();

    }

    then new

    public void new(str ActionParm)

    {

           super();

    }

    can you tell me how to pass the parameter?

    thanks again Martin Dráb .

  • Suggested answer
    Martin Dráb Profile Picture
    239,381 Most Valuable Professional on at

    Please use </> button in the rich formatting view to insert your code in a formatted way. Also, paying more attention to naming conventions would make your code more readable.

    public static client void main(Args args)
    {
        str ActionParameter = args.parmEnum();
        PendingOrderController       QOPOG;
    
        //define the new object for controller class
        QOPOG   = new PendingOrderController(ActionParameter);
    
        //set the report name and report design to run
        if (ActionParameter == "0")
        {
            QOPOG.parmreportname(ssrsreportstr(PendingOrders, PendingOrdersbyCustomer));
        }
        else if(ActionParameter == "1")
        {
            QOPOG.parmreportname(ssrsreportstr(PendingOrders,PendingOrdersbyCustomer));
        }
    
        //execute the report
        QOPOG.startoperation();
    }
    
    public void new(str ActionParm)
    {
        super();
    }

    Nevertheless the effect of your code is the same like this:

    public static client void main(Args args)
    {
        PendingOrderController controller = new PendingOrderController();	
        controller.parmReportName(ssrsReportStr(PendingOrders, PendingOrdersbyCustomer));
        controller.startOperation();
    }

    You never use your parameter for anything useful.

    To pass the value from main() to the controller object, you need an instance variable (= (in classDeclaration) and set its value from main(). One option is adding a custom variable and a parm method, but you can do it even simpler. You can pass args to parmArgs() and then access args object from prePromptModifyContract().

    Also, please learn how to use enums - your attempts to convert enum values to strings containing numbers makes no sense. The syntax for accessing enum values is EnumName::EnumElement, such as SalesStatus::Delivered.

  • Walid Gamal Profile Picture
    on at

    i use the same design right now but i will use another design after i finished this

    so i need this if condition with enum parameter

  • Martin Dráb Profile Picture
    239,381 Most Valuable Professional on at

    You're most welcome to include such functionality, but it's not related to the topic of this thread. Please follow my suggestion how to pass the value to prePromptModifyContract().

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!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 39

#2
Michel ROY Profile Picture

Michel ROY 14

#3
imran ul haq Profile Picture

imran ul haq 8

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans