Options

System Current Form => Customize Application Managment

aleix1979aleix1979 Member Posts: 213
Hello World,

That's a tough one for those experts out there. O:)

I want the No. Series Codeunit to apply one No. Series or another depending on which user is loaded and from which form is the current one (although No.Series CU is hardly called directly from a form).

So my idea is to keep a var in the No. Series Codeunit and keep informing the CU of the current form by some mod in Application Managment. Basically because I would be hard to mantain a modification from each form to No. Series and also because if you have 2 different forms it has to pick the real current one even if you just changed (being CU1 the only one executed in between)

With some Windows DLL you can control windows from the current or running programs but can't retrieve information from a particular Window (form) inside Navision. Don't even dear to ask the ID (they'll sentence you three days rounding about ParnerSource :wink: )

Well, any ideas?
Navision Developer

Comments

  • Options
    Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    Navision uses the primairy key in the sales header and purchase header to have different no.series. This is initialised on the form.

    Maybe you can add a new field and initialise this on the NewRecord trigger.

    This allows you to change the code in the NoSeries function.

    This will save you all the trouble of changing cu. 1 and stuff like that.
  • Options
    aleix1979aleix1979 Member Posts: 213
    Dank U Well Mark :wink:

    I'm afraid it doesn't solve the problem though.

    It's necessary to have different No.Series depending on the form so for instance a Sales Header type Invoice should get a different No.Series if got from form A than if got from form B and also depending on the user. This is stored in a table like that:
    1 Form
    2 User
    3 No. Series

    While in the table, I can't know which form is managing the table so... I also would like NOT to modify every table and NOT to modify every form but instead only NoSeriesManagement and Application Management.

    Mission Impossible still waiting for a genius 8)
    Navision Developer
  • Options
    rsfairbanksrsfairbanks Member Posts: 107
    I'm just a simpleton not a genius, but cannot you use the No Series Relationships?

    Use a Master number series for the form(s) and then identify which Related number series to select based on a new field in the No Series (eg user / role / dimenson value x)
  • Options
    aleix1979aleix1979 Member Posts: 213
    That is how is set currently. They (customer up in the square mile) have up to 5 different No.Series with the regular No. Series Relationship for say a Sales Invoice which has to be filled with different No.Series depending form which form they are working.

    It seems that they can't remember / create the apropiate No.Series for each document #-o
    Navision Developer
  • Options
    DenSterDenSter Member Posts: 8,304
    That's a tricky one.... what about if the user has 15 windows open, and 5 of them are in that table, you would have a hard time knowing where it came from. Plus, the numbering series logic is not fired from the form, it's fired from the tables mostly, so you'd have to add something to the table to temporarily store the form ID.

    I would probably add a function to the No Series codeunits to set the form ID before calling it for a new number, and modify it to look in that new table for which series to use.

    That way you'd still have to modify all tables that use the numbering series though, good luck taking on that problem ;)
  • Options
    aleix1979aleix1979 Member Posts: 213
    Well, I've already got the winning structure:

    A table:
    -Form
    -User
    -No. Series
    -Current Form (which is unique per subgroup of record with the same user)

    That way, unless two users enter with the same ID you would have a unique form selected when asigning a new Number :D

    Two modifications in the NoSeriesManagment codeunit:
    -In GetNextNo and InitSeries to use the No.Series from the coss-refered table instead of the one that is coming.

    One modification in the table itself:
    -Function UpdateCurrentForm(FormID) which will blank all Current Form fields for sub selection of the same User and tick the particular one. ( :twisted: :twisted: :twisted: For some stupid reason doesn't let me do neither a MODIFY or MODIFYALL in the table. :twisted: :twisted: :twisted: Neither let me do so in I move the whole lot to the codeunit. It says: "You cannot make any changes in the database from this trigger" :twisted: :twisted: :twisted: )

    So I don't need to change any table! 8)

    Only the original problem remains. How to know from CU1 which form is being created or moved to ("what about if the user has 15 windows open"). Otherwise I will have to use the OnFindRecord in each form which is a solution I can't be excited about. :?
    Navision Developer
  • Options
    DenSterDenSter Member Posts: 8,304
    What I said earlier... I would probably add a field to temporarily store the form ID to the table, and set the field to the form ID onaftergetrecord, that's the only way to make sure you got the right form id. Then the call to the numbering series codeunit would take that value to look up the right one.
  • Options
    aleix1979aleix1979 Member Posts: 213
    No, that would mean having to do modifications in the table and in the form and I don't want to make any of them. (so it can be for a generic No.Series) :roll:
    Navision Developer
  • Options
    DenSterDenSter Member Posts: 8,304
    That's like saying 'I want to go to Rome, but I don't want to travel there'. You have to do development to make it work a certain way. It does not do what you want it to do out of the box, so you will have to do development.
Sign In or Register to comment.