I want to create multiple PO's with one button

Demonic240
Member Posts: 65
I mentioned earlier in a previous thread that I am working on en expense form. One of the objectives of this form is to create a PO for each employee at once. I can create one PO at a time, however if I try to create multiple ones at once i get this message: You may not enter numbers manually. If you want to enter numbers manually, please activate Manual Nos. in No. Series P-ORD. I am using an InitSeries command within a repeat to create the PO number. Please help!
0
Comments
-
Hi,
Are you clearing the PO Header record before you update the fields on it?
eg.
CLEAR(POHeader);
POHeader.INIT;
...
...
POHeader.INSERT
Albert0 -
No I'm not, let me try that.0
-
Just tried it out. That worked for creating new PO Headers. I also tried adding a CLEAR(PL) to clear the Purchase Lines but each PO is showing the data for the first one.0
-
Hi
Are you doing something like thisIF Emp.FINDSET THEN REPEAT CLEAR(PO); PO.INIT; PO."Document Type" := PO."Document Type"::Order; PO.INSERT(TRUE); // This will get your number fill in other fields info PO.MODIFY; CLEAR(PL); PL.INIT; PL."Document Type" := PO."Document Type"; PL."Document No." := PO."No."; fill in other fields info PL.INSERT; UNTIL Emp.NEXT = 0;
Hope this helps
Albert0 -
This is what I have:
EETOLD:=''; Rec.SETCURRENTKEY("Employee No."); Rec.SETFILTER(Status,'<>posted'); IF FINDFIRST THEN BEGIN REPEAT IF Rec."Employee No."<>EETOLD {AND (EETOLD<>'')} THEN BEGIN CLEAR(PH); PurchSetup.GET; PH.INIT; NoSeriesMgnt.InitSeries('P-ORD','P-ORD',WORKDATE,PH."No.",PH."No. Series"); PH."Document Type":=PH."Document Type"::Order; PH.VALIDATE("Buy-from Vendor No.",Rec."Employee No."); (DATA) PH.INSERT; PH.MODIFY; CLEAR(PL); LineNo:=0; REPEAT EmployeeExpense3.SETFILTER("Employee No.",FORMAT(Rec."Employee No.")); Vend.GET("Employee No."); EmployeeName:=Vend.Name; Employee.GET("Employee No."); "Div/Dep":=Employee."Global Dimension 1 Code"; PL.INIT; LineNo+=1000; PL.FINDFIRST; PL.VALIDATE("Line No.",LineNo); PL."Document No.":=PH."No."; PL.VALIDATE("Document Type",PL."Document Type"::Order); PL.VALIDATE(Type,PL.Type::"G/L Account"); PL.VALIDATE("No.",EmployeeExpense3."O/H Account No."); (DATA) IF Amount<>0 THEN PL.INSERT; PL.VALIDATE("Shortcut Dimension 1 Code","Div/Dep"); IF EmployeeExpense3."Job No." <>'' THEN PL.VALIDATE("Job No.",EmployeeExpense3."Job No."); MODIFY; UNTIL EmployeeExpense3.NEXT=0; END; EETOLD:=Rec."Employee No."; UNTIL Rec.NEXT=0;
0 -
I have had a look at your code and have changed it
EETOLD:=''; Rec.SETCURRENTKEY("Employee No."); Rec.SETFILTER(Status,'<>posted'); IF FINDFIRST THEN REPEAT IF Rec."Employee No."<>EETOLD {AND (EETOLD<>'')} THEN BEGIN CLEAR(PH); PH.INIT; // Don't need this line //PurchSetup.GET; //NoSeriesMgnt.InitSeries('P-ORD','P-ORD',WORKDATE,PH."No.",PH."No. Series"); PH."Document Type":=PH."Document Type"::Order; PH.INSERT(TRUE); // Will exit the OnInsert trigger and get the next PO No. for you PH.VALIDATE("Buy-from Vendor No.",Rec."Employee No."); (DATA) PH.MODIFY; CLEAR(PL); PL.SETRANGE("Document Type" := PH."Document Type"; PL.SETRANGE("Document No.",PH."no."); IF PL.FINDLAST THEN LineNo := PL."Line No."; LineNo += 10000; EmployeeExpense3.SETFILTER("Employee No.",FORMAT(Rec."Employee No.")); IF EmployeeExpense3.FINDSET THEN REPEAT Vend.GET("Employee No."); EmployeeName:=Vend.Name; Employee.GET("Employee No."); "Div/Dep":=Employee."Global Dimension 1 Code"; PL.INIT; PL."Document Type":=PL."Document Type"::Order; PL."Document No.":=PH."No."; PL."Line No.":=LineNo; PL.Type:=PL.Type::"G/L Account"; PL.VALIDATE("No.",EmployeeExpense3."O/H Account No."); (DATA) PL.VALIDATE("Shortcut Dimension 1 Code","Div/Dep"); IF EmployeeExpense3."Job No." <>'' THEN PL.VALIDATE("Job No.",EmployeeExpense3."Job No."); IF Amount<>0 THEN BEGIN PL.INSERT; LineNo+=10000; END; UNTIL EmployeeExpense3.NEXT=0; END; EETOLD:=Rec."Employee No."; UNTIL Rec.NEXT=0;
Hope this gets you going. I'm not quite sure what you're trying to achive.
Do you want one PO Header for each employee and then multiple lines for each expense?
Albert0 -
Had a little think about this :-k
Maybe you want to do thisEETOLD:=''; Rec.SETCURRENTKEY("Employee No."); Rec.SETFILTER(Status,'<>posted'); IF FINDFIRST THEN REPEAT IF Rec."Employee No."<>EETOLD THEN BEGIN CLEAR(PH); PH.INIT; // Don't need this line //PurchSetup.GET; //NoSeriesMgnt.InitSeries('P-ORD','P-ORD',WORKDATE,PH."No.",PH."No. Series"); PH."Document Type":=PH."Document Type"::Order; PH.INSERT(TRUE); // Will exit the OnInsert trigger and get the next PO No. for you PH.VALIDATE("Buy-from Vendor No.",Rec."Employee No."); (DATA) PH.MODIFY; LineNo := 0; END; CLEAR(PL); PL.SETRANGE("Document Type" := PH."Document Type"; PL.SETRANGE("Document No.",PH."no."); IF PL.FINDLAST THEN LineNo := PL."Line No."; LineNo += 10000; EmployeeExpense3.SETFILTER("Employee No.",FORMAT(Rec."Employee No.")); IF EmployeeExpense3.FINDSET THEN REPEAT Vend.GET("Employee No."); EmployeeName:=Vend.Name; Employee.GET("Employee No."); "Div/Dep":=Employee."Global Dimension 1 Code"; PL.INIT; PL."Document Type":=PL."Document Type"::Order; PL."Document No.":=PH."No."; PL."Line No.":=LineNo; PL.Type:=PL.Type::"G/L Account"; PL.VALIDATE("No.",EmployeeExpense3."O/H Account No."); (DATA) PL.VALIDATE("Shortcut Dimension 1 Code","Div/Dep"); IF EmployeeExpense3."Job No." <>'' THEN PL.VALIDATE("Job No.",EmployeeExpense3."Job No."); IF Amount<>0 THEN BEGIN PL.INSERT; LineNo+=10000; END; UNTIL EmployeeExpense3.NEXT=0; END; EETOLD:=Rec."Employee No."; UNTIL Rec.NEXT=0;
Hope this helps [-o<
Albert0 -
Thanks. I'll try that out. What I want is 1 Header for each employee and a line for each expense.0
-
Ok, just tried out the code. It's working much better in terms of separating the lines for each employee. The issue I'm running into now is that each line for each employee is repeated three times. Not right after each other, but all of the lines will be inputed and then re-inputed twice more.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 322 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions