Assign Dimensions OnInsert Record

deprodepro Member Posts: 46
Guys,

I need to assign "Selesperson Code" and corresponding salespersons default dimension values to job when inserting record in Job table.

I wrote code like this in OnInsert trigger:
recSalesperson.SETRANGE("User ID",USERID);
IF (recSalesperson.FINDFIRST) THEN
    VALIDATE("Salesperson Code",recSalesperson.Code);

In OnValidate trigger i put this code:
FOR i:=1 TO 8 DO BEGIN  
  IF recDefaultDim.GET(DATABASE::"Salesperson/Purchaser", "Salesperson Code", GLSetupShortcutDimCode[i]) THEN
    ValidateShortcutDimCode(i, recDefaultDim."Dimension Value Code");
END;

ValidateShortcutDimCode function is standart Job Table function with code:
ValidateShortcutDimCode(FieldNumber : Integer;VAR ShortcutDimCode : Code[20])
DimMgt.ValidateDimValueCode(FieldNumber,ShortcutDimCode);
DimMgt.SaveDefaultDim(DATABASE::Job,"No.",FieldNumber,ShortcutDimCode);
MODIFY;

But when i try to insert new record to Job Table error message appear:
"Job No. XXX does not exist"

How can I avoid inserting record to Defoult Dimension Table before I inserted record to Job Table?

I`ve tried to use Insert in OnInsert trigger but it doesnt make sense, becouse of double inserting the same record.
Using temporary table to store my default dimension seems to be good solution but how can I retrive this record after inserting Job record?

Any ideas or suggestions?

Comments

  • deprodepro Member Posts: 46
    Or mayby this is impossible?

    ](*,)
  • jannestigjannestig Member Posts: 1,000
    Why wouldn't you assign the salesperson dimension and value against the job card?

    The dimension will then be inserted against the ledger entries anyway ????

    If you have different sales people, enter the salesperson against the job task lines instead?
  • deprodepro Member Posts: 46
    hi jannestig!

    Our client use Job Card as type of Transport Order.
    They aren`t use Job Task Lines.

    The reason why they use Jobs is to move dimension Value form Job Card to sales/purchase documents and to entries table.
    Using Jobs you can also accumulate all costs and profits according specific transport order.
    Jobs has that kind of funcionality so we use that part of standart NAV and accomodate it to customer needs.

    But next problem is that customer have to create a lot of transport order every day,
    so my objective is to make filling Job card as fast and easy as possible.

    I just wont to minimize no. of filelds to inserting data.
    Besides this users often forget to put Dimensions Codes.

    Regards,
    Depro
  • rhpntrhpnt Member Posts: 688
    Check the standard dimension and dim. value functionality for items and how it is used when inserting items into sales lines.
Sign In or Register to comment.