Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Answered

passing the value of selected record to the fields in dialogue box runbase.

Posted on by 210

pastedimage1578314246584v1.pngpastedimage1578314280677v2.png

I want to pass the value of 1st two fields of the selected row to the dialogue box.

  • vikash_ Profile Picture
    vikash_ 210 on at
    RE: passing the value of selected record to the fields in dialogue box runbase.

    Thank you.

  • Verified answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: passing the value of selected record to the fields in dialogue box runbase.

    Try this, all new and modified code is marked with //New and //Modified comments. This example handles only StudentId field, but you can apply the same logic to others. I have assumed that the type of the caller record is "MyTable", you of course need to replace it with your table name.

    class TM_CreateIssue extends RunBase
    {
        DialogField Bookid;
        DialogFIeld Studentid;
        DialogFIeld Studentname;
        DialogFIeld BookBarcode;
    
        TM_Student  student;
        TM_BookTrans   bookTrans;
    
        //CustTable   custTable;
        //CustAccount custAccount;
        public Object Dialog()
        {
            Dialog dialog;
            ;
     
            dialog = super();
     
            // Set a title for dialog
            dialog.caption( 'Create issue');
     
            // Add a new field to Dialog
            Bookid = dialog.addField( extendedTypeStr(TM_Student), 'Book id' );
            BookBarcode = dialog.addField( extendedTypeStr(TM_Student), 'Book barcode' );
            Studentname = dialog.addField( extendedTypeStr(TM_Student), 'Student name' );
    
            Studentid = dialog.addFieldValue(extendedTypeStr(TM_Student), student, 'Student id' ); // Modified
    
            return dialog;
        }
    
        // New 
        public TM_Student parmStudent(TM_Student _student = student)
        {
            student = _student;
    
            return student;
        }
    
        public boolean getFromDialog()
        {
            // Retrieve values from Dialog
            bookTrans.BookId = Bookid.value();
            bookTrans.BookBarcode = BookBarcode.value();
            bookTrans.StudentName = Studentname.value();
            bookTrans.StudentId = Studentid.value();
     
            return super();
        }
    
        public void run()
        {
            info("stored");
        }
    
        public static void main(Args _args)
        {
    	MyTable myTable = _args.record(); // New
            TM_CreateIssue createIssue = new TM_CreateIssue();
    
    	createIssue.parmStudent(myTable.Student); // New
     
            // Prompt the dialog, if user clicks in OK it returns true
            if (createIssue.prompt())
            {
                createIssue.run();
            }
        }
    
    }

  • vikash_ Profile Picture
    vikash_ 210 on at
    RE: passing the value of selected record to the fields in dialogue box runbase.

    class TM_CreateIssue extends RunBase
    {
        DialogField Bookid;
        DialogFIeld Studentid;
        DialogFIeld Studentname;
        DialogFIeld BookBarcode;
    
        TM_Student  student;
        TM_BookTrans   bookTrans;
    
        //CustTable   custTable;
        //CustAccount custAccount;
        public Object Dialog()
        {
            Dialog dialog;
            ;
     
            dialog = super();
     
            // Set a title for dialog
            dialog.caption( 'Create issue');
     
            // Add a new field to Dialog
            Bookid = dialog.addField( extendedTypeStr(TM_Student), 'Book id' );
            BookBarcode = dialog.addField( extendedTypeStr(TM_Student), 'Book barcode' );
            Studentname = dialog.addField( extendedTypeStr(TM_Student), 'Student name' );
            Studentid = dialog.addField( extendedTypeStr(TM_Student), 'Student id' );
            return dialog;
        }
    
        public boolean getFromDialog()
        {
            // Retrieve values from Dialog
            bookTrans.BookId = Bookid.value();
            bookTrans.BookBarcode = BookBarcode.value();
            bookTrans.StudentName = Studentname.value();
            bookTrans.StudentId = Studentid.value();
     
            return super();
        }
    
        public void run()
        {
            info("stored");
        }
    
        public static void main(Args _args)
        {
            TM_CreateIssue createIssue = new TM_CreateIssue();
     
            // Prompt the dialog, if user clicks in OK it returns true
            if (createIssue.prompt())
            {
                createIssue.run();
            }
        }
    
    }

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: passing the value of selected record to the fields in dialogue box runbase.

    I assume you already have some code. It would be easier to help if you showed it.

    Anyway, in Main method of your class, you can get the selected record by args.record(). And from that record you can read the values of different fields.

    When creating the dialog, you can set up values in the fields when creating the fields, by calling myDialog.addFieldValue method

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans