I want to pass the value of 1st two fields of the selected row to the dialogue box.
I want to pass the value of 1st two fields of the selected row to the dialogue box.
Thank you.
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(); } } }
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(); } } }
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
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,280 Super User 2024 Season 2
Martin Dráb 230,214 Most Valuable Professional
nmaenpaa 101,156