If that can help you, I have done something similar to this but for 
PackingSlip.  It is not posting the packingslip automatically, it 
just brings the validation form with some sales order selected.  You 
could push it further and automatically click "Ok" on the form to 
post them automatically.

Here's what I've come up with :

QueryBuildRange range;
Args args = new Args(this);
SalesTable salesTabToSelect;
// SalesTable_ds is a FormDataSource linked to an invisible grid on 
my form.
QueryBuildDataSource salesQBDS = SalesTable_ds.query().dataSourceNo
(1);

salesQBDS.addRange(fieldNum(SalesTable, CustAccount)).value
(custAccountRange);
SalesTable_ds.executeQuery();

// Select all lines of the grid
salesTabToSelect = SalesTable_ds.getFirst();
while (salesTabToSelect) {
    SalesTable_ds.markRecord(salesTabToSelect, true);
    salesTabToSelect = SalesTable_ds.getNext();
}

args.parmEnumType(typeId(DocumentStatus));
args.parmEnum(DocumentStatus::PackingSlip);
args.record(SalesTable);

SalesFormLetter::main(args);

Good luck!

Steeve...

--- In Axapta-Knowledge-Village@yahoogroups.com, "mstrillian" 
<[EMAIL PROTECTED]> wrote:
>
> Hi everyone,
> 
> I want to use a string of customer accounts to create a query to 
post 
> multiple invoices at one time.
> 
> Here is my code:
> 
>     Query           query = new Query();
>     QueryRun        queryRun;
>     SalesTable      salesTable;
>     SalesLine       salesLine;
>     SalesFormLetter salesFormLetter;
>     ;
> 
> // strCustAcct has multiple customer accounts in it, separated by 
commas
> query.addDataSource(tableNum(SalesTable)).addRange(fieldNum
> (SalesTable,CustAccount)).value(strCustAcct);
> 
> salesFormLetter = SalesFormLetter::construct
(DocumentStatus::Invoice);
> salesFormLetter.queryChooseLines().query(query);
> ttsbegin;
>     salesFormLetter.update(salesTable, systemDateGet(), 
> SalesUpdate::All, AccountOrder::None, false, false);
> ttscommit;
> 
> I'm getting an error on the queryChooseLines method that tells me 
that 
> SysQueryRun object not initialized. I tried putting a queryRun = 
new 
> QueryRun(query); before constructing the SalesFormLetter, but still 
got 
> the same error.
> 
> I don't even know if I'm doing the SalesFormLetter part correctly. 
How 
> do I tell SalesFormLetter what query I want it to use to post my 
sales 
> orders? Also, is the update enough to post the invoices or do I 
have to 
> call SalesFormLetter.run() as well? Or instead?
> 
> Any help would be appreciated.
> 
> Thanks!
>


Reply via email to