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, ...
Answered

To open report using selected sales order on clicking menu item button.

(0) ShareShare
ReportReport
Posted on by 1,836

I have created menu item button named "situationary declaration " in all sales order form so when i clicked on this button it will open the report 

with the dilogue box having invoice id parameter but i dont want that , what i want is 

if i open specific sales order and then click "situationary declaration " button it should directly open the report for that sales order which having invoice id .

no need of dilogue box is there report should directly open on click of menu item button.

can someone suggest how can i get this done.

pastedimage1672902369773v1.png

pastedimage1672902420233v2.png 

I have the same question (0)
  • Suggested answer
    GirishS Profile Picture
    27,827 Moderator on at

    Hi Dineshkarlekar,

    You need to disable the report parameter dialog in the controller class.

    On the main method you can set the parmShowDialog(false);

    On the controller class main method you will get the args and set the parmShowDialog to false.

    On the "prePromptModifyContract" method you can pass the invoice id to contract class parameters.

    Thanks,

    Girish S.

  • Dineshkarlekar Profile Picture
    1,836 on at

    I  have set par set the parmShowDialog(false);

    here is my code .

    still dilogue box is seems to be appearing , if i want to open report directly on the click of menu item button for specific sales order invoice id do i need to write some code for that.

    thanks 

    regards,

    Dinesh. 

    [DataContractAttribute]
    class Dev_DocumentsDeclarationContract
    {
        
        CustInvoiceId      InvoiceId;
    
        [DataMemberAttribute(identifierStr(CustInvoiceId))]
        public  CustInvoiceId  parmCustInvoiceId( CustInvoiceId   _CustInvoiceId  = InvoiceId)
        {
            InvoiceId = _CustInvoiceId ;
            return   InvoiceId;
        }
    
    }
     

    class  Dev_DocumentsDeclarationController    extends SrsReportRunController
    {
        Dev_DocumentsDeclarationContract        Contract;
        SalesOrderExim                         dataTableOne;
           
    
        protected void prePromptModifyContract()
        {
            super();
            if (this.parmArgs() && this.parmArgs().record())
            {
                contract = this.parmReportContract().parmRdpContract() as Dev_DocumentsDeclarationContract;
                datatableone = this.parmArgs().record();
                contract.parmCustInvoiceId(dataTableOne.InvoiceId);
            }
    
        }
    
        static void main(Args args)
        {
            SalesOrderExim                                       dataTableOne;
            Dev_DocumentsDeclarationController                 ssrsController;
            datatableone = args.record() as                   SalesOrderExim ;
            ssrsController= new  Dev_DocumentsDeclarationController();
            ssrsController.parmArgs(args);
    
            ssrsController.parmReportName(ssrsReportStr(Dev_DocumentsDeclerationRpt,PrecisionDesign1));
            ssrsController.parmShowDialog(false);
            ssrsController.parmLoadFromSysLastValue(false);
            ssrsController.startOperation();
        }
    
    }
     

  • GirishS Profile Picture
    27,827 Moderator on at

    Code seems to be correct.

    Add debugger point on the controller class main method and see whether debugger is hitting.

    On the output menu item have you mapped the controller class?

    I guess you mapped the SSRS report instead of controller class on the menu item.

    Thanks,

    Girish S.

  • Suggested answer
    Bharani Preetham Peraka Profile Picture
    3,634 Moderator on at

    If you have added that button, situationary declaration then you can simply remove that parm method for the invoice Id and set parmshowdialog(false) in main method of controller. And you can write an event handler or a method on clicked of that button so that on click, it should check for that sales order having journald and will pick that and can call the controller class.

    But why only 1 sales order will have a journal I'd? Can you tell me exact requirement? Because there would be many journal IDs with multiple sales orders if I am not worng.

  • Dineshkarlekar Profile Picture
    1,836 on at

    yes you were right "I guess you mapped the SSRS report instead of controller class on the menu item."

    but now i have mapped it with controller class but getting exception 

    pastedimage1672926690123v1.png 

  • GirishS Profile Picture
    27,827 Moderator on at

    Caller record seems to be SalesTable but you are getting the caller record as SalesOrderExim.

    Try to set the menu item DataSource as SalesOrderExim or change the caller record to SalesTable based on the requirements.

    Thanks,

    Girish S.

  • Dineshkarlekar Profile Picture
    1,836 on at

    yes you are exactly right there may be more than one journal id for one sales order but

    but at initial level i am creating sales order making them invoiced only so they can have only one journal id ,

    i am doing this for test purpose only if the sales order is having multiple journal id then i have to enable dilogue box and keep selection(lookup )for invoice id/journal id that is the issue afterwards i have to do but now this much i have to get done.

    as you told me if i write event handler on click method of menu button

    ,what code i have to write , is that with select statement with relation to pass invoice id in controller. i am mentioning my DP CLASS  below .can you plz suggest anything on this.

    [SRSReportParameterAttribute(classstr(Dev_DocumentsDeclarationContract))]
    class Dev_DocumentsDeclarationDp  extends SRSReportDataProviderBase
    {
        Dev_DocumentsDeclerationTbl       dev_DocumentsDeclerationTbl;
       
        [SrsReportDataSetAttribute(tableStr('dev_DocumentsDeclerationTbl'))]
        public dev_DocumentsDeclerationTbl getdev_DocumentsDeclerationTbl()
        {
            select * from dev_DocumentsDeclerationTbl;
            return        dev_DocumentsDeclerationTbl;
        }
    
        public void processReport()
        {
    
            CustInvoiceJour       objcustInvoiceJour;
            Salestable            objSalestable;
            SalesOrderExim 		  objsalesOrderExim;
            SalesOrderEximLines   objSalesOrderEximLines;
    
            Dev_DocumentsDeclarationContract contract = this.parmDataContract();
            str 20 InvoiceId = contract.parmCustInvoiceId();
                
            Query q = new Query();
            QueryBuildDataSource qbdsCustInvoiceJour  = q.addDataSource(tableNum(CustInvoiceJour));
            QueryBuildDataSource qbdsSalestable       = qbdsCustInvoiceJour.addDataSource(tableNum(Salestable));
            qbdsSalestable.addLink(fieldNum(CustInvoiceJour, SalesId),fieldNum(Salestable, SalesId));
            qbdsSalestable.joinMode(JoinMode::InnerJoin);
            //qbdsSalestable.relations(true);
            QueryBuildDataSource  qbdsSalesOrderExim  = qbdsSalestable.addDataSource(tableNum(SalesOrderExim));
            qbdsSalesOrderExim.relations(true);
    
            if (InvoiceId != "")
            {
                QueryBuildRange qbr    = qbdsSalesOrderExim.addRange(fieldNum(SalesOrderExim , InvoiceId));
                qbr.value(queryValue(InvoiceId ));
            }
          
              
    
            QueryRun qr = new QueryRun(q);
    
            while(qr.next())
            {
                Companyinfo               companyinfo = companyinfo::find();
                SalesLine                 objsalesLine;
                CustTable                 objcustTable;
                objcustInvoiceJour       = qr.get(tableNum(CustInvoiceJour));
                objSalestable            = qr.get(tableNum(SalesTable));
                objSalesOrderExim		 = qr.get(tableNum(SalesOrderExim));
                
    
    
                dev_DocumentsDeclerationTbl.Exporter            =  companyinfo::find().Name;
                dev_DocumentsDeclerationTbl.NameOfCustomsBroker =   "";
                dev_DocumentsDeclerationTbl.IdentityCardNO      =   "";
                dev_DocumentsDeclerationTbl.CustDesignation     =   "";
                dev_DocumentsDeclerationTbl.ExpDesignation      =   "";
                dev_DocumentsDeclerationTbl.insert();
    
    
              
            }
        }
    
    }
      

  • Suggested answer
    Bharani Preetham Peraka Profile Picture
    3,634 Moderator on at

    After seeing your code and as I said earlier until and unless you are removing the parm method it will ask for the value else it will give error if you try to make that dialog(false).

    So the only change would be in the event handler class or coc, like onclicked event handler or clicked method, based on the records available in the salestable just check how can you get the journalid. If you are able to get the journal ID, simply create a table buffer and pass that table buffer to args buffer and args to main method of controller and from the controller args you can again pick the journal I'd to give the query in dp class.

    The basic idea here is on clicking,  i am calling the main method of controller which will call dp class.

  • Dineshkarlekar Profile Picture
    1,836 on at

    hi ,

    i have written the code on clicked event of button but how can i pass this invoiced id to my parameter , can you plz help me out as i am not having multiple invoice id in my sales order , there is only single invoice id created for the sales order as per requirement. here is  the code below.

     [FormControlEventHandler(formControlStr(SalesTable, Dev_SituationaryDeclaration), FormControlEventType::Clicked)]
        public static void Dev_SituationaryDeclaration_OnClicked(FormControl sender, FormControlEventArgs e)
        {
            select forupdate salesOrderExim
                where   salesOrderExim.RefrenceRecId == this.RecId;
    
            if(this.SalesStatus==SalesStatus::Invoiced)
            {
                select InvoiceId,InvoiceDate  from custInvoiceJour
                    where custInvoiceJour.SalesId == this.SalesId;
            }
    
        }

  • GirishS Profile Picture
    27,827 Moderator on at

    Refer to the below blog.

    https://community.dynamics.com/365/financeandoperations/b/goshoom/posts/printing-reports-from-code-in-d365fo

    On the above blog it will download this as file. To show it in screen just change the SRSPrintMediumType to "Screen"

    Thanks,

    Girish S.

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 565 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 254 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans