Hello all,
I seem to have run into a bit of a pickle with automating dimensions. When a new customer is added I have inserted some code to automatically insert a 'Customer' Dimension, which works fine. However when I try to insert another Dimension ('Resource') which should be equal to the 'Salesperson Code', it returns an error message. The Dimension 'Resource' does have values which are salesperson codes, not sure how I go about adding the dimension so that when a salesperson code is added on the customer card the 'Resource' dimension equal to Salesperson Code is added. The code I have inserted is as follows:
DimValue.INIT;
DimValue."Dimension Code" := 'RESOURCE';
DimValue.Code := Customer."Salesperson Code";
DimValue.INSERT;
DefaultDim.INIT;
DefaultDim."Table ID" := 18;
DefaultDim."No." := "No.";
DefaultDim."Dimension Code" := 'RESOURCE';
DefaultDim."Dimension Value Code" := "Salesperson Code";
DefaultDim."Value Posting" := DefaultDim."Value Posting"::"Code Mandatory";
DefaultDim.INSERT;
Any ideas please?
0
Answers
Where have you put this code?
Should be OnValidate of Sales Person Code field of the Customer Table
also add
IF "SalesPerson Code" <> '' THEN BEGIN
your coding goes here
END;
Hope this helps
Albert
An easier way is to set-up the dimension against the salesperson code and it will be inherited on sales transactions.
Dynamics Nav Add-ons
http://www.simplydynamics.ie/Addons.html
The Dimension Value already exists
You are inserting into the dimension value table each time which is a master table. Check if the value exist first before insert.
Dynamics Nav Add-ons
http://www.simplydynamics.ie/Addons.html
This is the reason I recommend using the dimension on the salesperson. To operate this the resource dimension is setup against the salesperson and then when the customer is selected on a sales order for example the resource dimension is then added to the order. This will also solve the problem you will hit, that if the user changes the salesperson on the card then you will need to rewrite the default dimension value.
Anyway the code you would need is
Also an interesting discussion on dimensions you might find useful.
viewtopic.php?f=23&t=29747
Dynamics Nav Add-ons
http://www.simplydynamics.ie/Addons.html
Thank You for taking the time to answer my question much appreciated.
Dynamics Nav Add-ons
http://www.simplydynamics.ie/Addons.html