user1300922
user1300922

Reputation: 207

Call child form programmatically with parameter / filter

I'm creating a customization where on a click of a button, I need to allocate a charge for a particular purchase order / invoice journal.

From the front end, I would accomplish this by following the purchase order life-cycle and invoicing it. I would then go under the invoice tab of the PO, click Invoice Journals -> Charges -> Adjustment . This will open up my desired form where I will select a charges code, charges value, currency and category, and then I will click 'Ok' and have the system take care of the rest of the process.

Form name: MarkupAllocation_VendInvoiceTrans enter image description here

Parent form Name: VendInvoiceJournal

enter image description here

You can see that the child form gets called with a few parameters such as the invoice number, there obviously needs to be that link. If I go into the AOT under forms, I right click and open up VendInvoiceJournal, but I wouldn't be able to open up MarkupAllocation_VendInvoiceTrans because it requires parameters.

Objective:

A: To open MarkupAllocation_VendInvoiceTrans through code where I manually pass those parameters to link to the parent table. I would provide the invoice number and such. The objective is to skip opening the parent table and manually going into the adjustments. I want to open that form directly and have it link to whichever record I specify.

B: I need to be able to pass a _ChargesValue parameter and have that be pre-populated for me. I don't know if this is possible, so I wanted to ask and confer. Ideally, I should be able to click a button on my custom form, and have MarkupAllocation_VendInvoiceTrans form directly open for a specified invoice, with pre-populated values on the line.

I know I should be tackling this problem one step at a time, so step A is priority number one.

I can open up the parent form with relative ease like so, but I cannot do the same for the child form. Obviously the same time of approach won't work, as I need to specify the relationship of the parent table before I open it.

private void allocateMarkup()
    {
      Object formRun;
      Args args = new Args();

      VendInvoiceJour jourTable;    

      ;

      select * from jourTable where jourTable.PurchId == 'PO000001191';      
      args.name(formstr(VendInvoiceJournal));
      args.record(jourTable);

      formRun = ClassFactory.formRunClass(args);
      formRun.init();
      formRun.run();
      formRun.wait();

     }

How would I be able to do so?

(Side note, I realize this whole form calling could be avoided if do all the transactions programmatically instead of letting the out of the box functionality handle it, but the markup and allocation logic is a beast of it's own and to me seems much more complicated than doing this. If someone has done it this manual way, any help on that would be greatly appreciated as well)

Upvotes: 0

Views: 662

Answers (1)

Alex Kwitny
Alex Kwitny

Reputation: 11544

If I read your post right, you just want to open the Charges>Adjustment for a certain invoice. Here is one simple method:

MarkupAdjustment  markupAdjustment = new MarkupAdjustment();
markupAdjustment.vendInvoiceJour(VendInvoiceJour::findFromPurchId('PO 120079'));
markupAdjustment.run();

Upvotes: 1

Related Questions