How to pass parameters on forms (Urgent!)

mike_espinamike_espina Member Posts: 55
edited 2006-06-02 in Dynamics AX
Experts,

How do I pass parameters to form. I have made a job that calls a certain form. What I want is that, there is a parameter that I want to pass in the job and get that parameter in the form when the form is called. Take note that I dont have a license in making a class.

thank you very much.

Mike

Comments

  • MugurMugur Member Posts: 93
    You need to search in the Axapta dev guide for the Args class\Using forms. The args helps passing parms between objects. See also Args definition in the AOT\Sys documentation.
    Kind regards,

    Ciprian Dudau
    Axapta Developer
  • kashperukkashperuk Member Posts: 53
    Here is an example of code:
        Args                    myArgs = new Args(); 
        FormRun                 formRun; 
        DirectPurchLines        myDirectPurchLines; 
        DirectPurchId           myDirectPurchId; 
        DirectPurchTable        myDirectPurchTable; 
        ; 
    // create an object of class Args and passes the DirectPurchLineForm into it - this
    // is the object that is being called
        myArgs = new Args(formstr(DirectPurchLinesForm)); 
    // this identifies the calling object
        myArgs.caller(this); 
    //This function passes a string parameter into the called object
        myArgs.parm(StrFMT("%1\nedit", myDirectPurchId)); 
    
    //Creates a FormRun object based on what we inserted into args
        formRun = ClassFactory::formRunClassOnClient(myArgs); 
    //calls the init() method of the created form
        formRun.init(); 
        formRun.run(); 
        formRun.wait();  
    

    Then, in the init method of your called form you add the following code to see the result:
    //this returns the args object that was passed on to the form
        myArgs          = element.args(); 
    // this line reads the passed string parameters (delimiter is \n)
        myDirectPurchId = strline(myArgs.parm(),0); 
        myPrm           = strline(myArgs.parm(),1);  
    

    Good luck.
    And do read about it in the Dev Guide that was advised to you.
    Vanya Kashperuk,
    My blog - http://kashperuk.blogspot.com
    MorphX IT in Russian - http://www.lulu.com/content/723888
    Inside Dynamics AX 4.0 in Russian - http://www.ozon.ru/context/detail/id/3714582
Sign In or Register to comment.