declare arrays

kikkoman
Member Posts: 57
i know this may be a simple question, but i need to add a dimension code to a posted purchase inv. line, and the dimension is called "Employee". I am a newbie, and I know that you can have multiple Lines for each Header. Anyhow, I went to the Posted Puch. Invoice Subform, and I added a column called Employee Code. Anyhow, I was able to show the Dimension code when the form loads b/c I filtered the Posted Docuement Dimension by "Table ID", "Document No", and "Dimension Code". The problem I have is that when I have like 3 lines on the Posted Purch. Inv form, it shows for all 3 lines the Employee Code for the 1st line. This is not correct b/c each line can have a different Employee Code. I was thinking that maybe I can use an array and then assign the textbox for EMployee code on my form to the array, but I don't know if I can do this or not. Also i have looked on this forum and couldn't find how to declare arrays
Can someone please help me with this. How to declare arrays correctly. And if my method of assigining the SourceExpr for the textbox for Employee Code to the array will work, or is there another easy way of doing this??? I'm sure there has to be!!!! any help is greatly appreciated.

0
Comments
-
Hi,
Have you tried assigning the value to your variable at the OnAfterGetRecord section of the subform? That should do it. Under most circumstances you shouldn't need to use an array. However, to set the dimensions of an array you need to look at the properties of your variable.
I hope I understood your need and that this helps.TecSA Malaysia
Those of you who think you know everything are annoying to those of us who do. -
David Brent0 -
yes i assigned my value to my variable and i get the correct code, but if the line has more than 1 entry, all those entries get assigned to the very first one. for instance, the first line the employee code is martin, then if there are like 3 lines, then they all are martin, when it should be 1(martin), 2(brad), 3(sarah). if i just have a variable named EmpCode and assign that variable to the SourceExpr of the textbox, no matter what, all the lines are going to be the same b/c the variable is assigned to the SourceExpr, that is why I was thinking about using an array. Does this make sense? Im sorry if it doesn't.0
-
Well, I did a simple test:
In the OnAfterGetRecord of the Subform:
myvar := format("line no.");
myvar = code 10
I added a new column to the subform and made SourceExpr myvar
It shows each line number correctly.
So... I'm guessing your problem might be in the code you use to retrieve the dimension value for each line.TecSA Malaysia
Those of you who think you know everything are annoying to those of us who do. -
David Brent0 -
EmpCode:='';
PostedDocDimension.RESET;
PostedDocDimension.SETRANGE("Table ID", DATABASE::"Purch. Inv. Line"); {filter by table "Purch.Inv.Line" b/c that is where the
Posted Invoice Doc go. }
PostedDocDimension.SETRANGE("Document No.","Document No."); {filters the "Document No." field in table PostedDocDimension with
the field named "Document No." that is in this table,"Purch. Inv. Line" }
PostedDocDimension.SETRANGE("Dimension Code", 'EMPLOYEE');
//Employee is the 3rd dimension I need to filter
IF PostedDocDimension.FIND('-') THEN
REPEAT
EmpCode:=PostedDocDimension."Dimension Value Code";
//this will only get the last match of Employee Code and set all
//lines in Posted Purchase Invoice(line) to it, which is wrong b/c
//they can be different.
UNTIL PostedDocDimension.NEXT <=0;
Here is how my code looks like in the OnAfterGetRecord()
this is of course incorrect b/c all the empcodes on the form will be the same. Are you suggesting that I use the FORMAT to format my source expression??? It makes sense when you do it, but when I try, it doesn't work. It may be where I place that line of code???0 -
With your solution you are missing the SETRANGE on the "line no." and you don't need the repeat:
PostedDocDimension.RESET; PostedDocDimension.SETRANGE("Table ID", DATABASE::"Purch. Inv. Line"); PostedDocDimension.SETRANGE("Document No.","Document No."); PostedDocDimension.SETRANGE("Line no.","line no."); PostedDocDimension.SETRANGE("Dimension Code", 'EMPLOYEE'); IF PostedDocDimension.FIND('-') THEN EmpCode:=PostedDocDimension."Dimension Value Code";
You could of course just do this:clear(EmpCode); If postedDocDimension.get(DATABASE::"Purch. Inv. Line","Document No.","line no.",'EMPLOYEE') then EmpCode:=PostedDocDimension."Dimension Value Code";
The format in my example has nothing to do with your problem.. just a red herring I threw inTecSA Malaysia
Those of you who think you know everything are annoying to those of us who do. -
David Brent0 -
sweet....it works!!! hmm, i didn't know you had to place the RANGE on the "Line No." as well....doh!!! Thanks a bunch!!! I also like your short-handed version of my code. Alot more efficient. This is my 2nd week working with Navision. I have programmed before, but never with Navision, so I'm getting myself up to par with the material, or at least trying to. I'm sure glad for this website and for people like you. Very helpful. I hope to gain as much knowledge as I can so I can help others also....return the favor!!!hehehe
thanks,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
- 320 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