Dynamics NAV Web Services Purchase Invoice page setting line dimensions

Hello all-

I’m trying to set the dimensions per line in the Purchase Invoice page for NAV 2016. I can insert a record, but when I try to set any global or shortcut dimensions, I get an error:

The field Project Code of table Purchase Line contains a value (RICHARD LUM) that cannot be found in the related table (Dimension Value).

I get similar messages when I try to create a record with another dimension value. In web services, exposed the 51 Page Purchase Invoice.

In C\AL code, using a record for Dimension Set Entry to populate the lines, but don’t know how to go about this in C# web services?



this error is usually cause by not having this value in the Dimension Value table.

For each dimension the values have to be created in the related dimension value table.

1.Departments/Financial Management/Setup/Dimensions

2.Open Dimensions.

3.Get to the row where PROJECT CODE is located.

4.Click on “Dimension Values” in the ribbon and define the possible values in the next page.


best regards,

Hello Thomas-

Thank you for the quick reply. Yes, I understand the error itself. Makes sense, but it just seems odd that you cannot dynamically just set the dimensions, like in C\AL. Meaning, I don’t have to do the steps 1-4. Here is my code in C\AL.

IF hasDimensions = TRUE THEN BEGIN
// reset flag
hasDimensions := FALSE;

// set new dimensions get the set id first

DimSetID_L := dimCodeUnit.GetDimensionSetID(DimensionRec);

fieldNo := lineRec.FIELDNO(“Dimension Set ID”);
field := lineref.FIELD(fieldNo);
field.VALUE := DimSetID_L;


I think what my problem is that I’m not matching the dimensions up? How would you determine what shortcut belongs to what?

I have 8 right by default? And I have Shortcut_Dimension_1_Code, Shortcut_Dimension_2_Code, etc… to 8 in C#. I’m pretty sure I’m setting them in the right order. Is there a way to know for sure in any tables? I just feel like I’m missing something here. Like I’m trying to set Dim 1 with Dim 2 values, etc… or Dim 3 with Dim 4 values? That would explain the message.



you can determine which shortcurt belongs to which dimension in the General Ledger Setup(The table has the same name in SQL Database.)

SELECT [Global Dimension 1 Code]
,[Global Dimension 2 Code]
,[Shortcut Dimension 1 Code]
,[Shortcut Dimension 2 Code]
,[Shortcut Dimension 3 Code]
,[Shortcut Dimension 4 Code]
,[Shortcut Dimension 5 Code]
,[Shortcut Dimension 6 Code]
,[Shortcut Dimension 7 Code]
,[Shortcut Dimension 8 Code]
FROM [Demo Database NAV (9-0)].[dbo].[CRONUS International Ltd_$General Ledger Setup]

best regards,

Yes, that is the order I am following on General Ledger Setup, when I set Dim 2 Code to values for Dim 2 Code, it gets the same message. What I remember from before changes in 2009R2, you have to set the dim set ID, to set them in C\AL, so I didn’t know do I need to expose the Codeunit for DimensionManagement and do the same in C# I do in C\AL? It doesn’t seem to work setting it PurchLine.Shortcut_Dimension2_Code, the first dimension seems to set correctly, but as soon as I add the second dim, it fails. I have confirmed the value for dim 2 is a value that is for dim 2.



The validation for ShortcutDimensionCode2 is already defined in the table. I think you should just insert the Value into ShortcurtDimension2Code without any other coding.

best regards,

Thanks Thomas, it doesn’t seem to be working. I have to get this functionality for my project, when I find the answer, I’ll post.