Automated Dimension

tazzy30
Member Posts: 52
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?
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
-
Hi,
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
Albert0 -
Hi,
An easier way is to set-up the dimension against the salesperson code and it will be inherited on sales transactions.0 -
Thank you Albert for your reply i had the code within the Salesperson Code trigger and added your code but still no luck. I get the following error message:
The Dimension Value already exists0 -
Hi,
You are inserting into the dimension value table each time which is a master table. Check if the value exist first before insert.0 -
Thank you Dave for your reply, would i need to change the code so instead of inserting it finds the value then inserts, because I want it to find the value from that master table and match it to the salesperson code inserted on the customer card, and if the salesperson code is changed the resource dimension is also updated?0
-
Hi,
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 isif not DimValue.get( 'RESOURCE', Customer."Salesperson Code" ) then begin DimValue.INIT; DimValue."Dimension Code" := 'RESOURCE'; DimValue.Code := Customer."Salesperson Code"; DimValue.INSERT; end;
Also an interesting discussion on dimensions you might find useful.
viewtopic.php?f=23&t=297470 -
Your absolutely right in what you had said first, applying the resource dimension to the salesperson, wasn't sure whether that would have changed the dimension as well if changed on an order, but it does.
Thank You for taking the time to answer my question much appreciated.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