[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2349
  • Last Modified:

MS Dynamics AX 2009 :: Number Sequence for New Document

Hi Experts,

I am about to create a new project but one of the very first steps is to implement a new numbering sequence. Can someone please advise me.....


Thanks.
0
Marius0188
Asked:
Marius0188
  • 10
  • 6
2 Solutions
 
Marius0188Author Commented:
I will be producing a new document which should use it's own numbering sequence. Can I simply use the wizard or should I code as well.

And how do I link the number sequence to the actual field in the table?
0
 
AgrippineCommented:
Hi,

you will have to do some coding as well - there are a few places that have to be adjusted.
Please have a look at the following free e-book:
http://download.microsoft.com/download/2/5/8/258C8894-B94A-4A87-81EA-4DBB9776F8F2/622579eBook.pdf 

See page 147 and following. The book is great anyway and you will find many useful information there.

HTH
0
 
Marius0188Author Commented:
Hi HTH,

I have followed the text books example but still not getting it right.
Can you please explain  in more detailed steps.


Thanks.
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
AgrippineCommented:
uuuh, sorry.
HTH was short for "hope this helps" ... :-)

Could you tell me where you are stuck?

Regards,
agrippine
0
 
Marius0188Author Commented:
Ooh sorry. Hehhehe :)
Was wondering what happened to you....

OK I have create a new EDT.
I also create a new table and add 1 field and assigning the EDT to the field.
But when adding a new line in the table the field should populate automatically according to my number sequence.

I have done no coding yet. Not too sure where if required...
0
 
AgrippineCommented:
Well, depending on which "module" your field belongs to, you will have to add code to one of the number sequence classes. Let's assume you are programming for the inventory module, then you will add code to the class NumberSeqReference_Inventory, method loadModule.

You will find many blocks similar to the following:
    /* Setup item id */

    numRef.dataTypeId              = typeId2ExtendedTypeId(typeid(ItemId));
    numRef.referenceHelp           = literalStr("@SYS53849");
    numRef.WizardContinuous         = false;
    numRef.WizardManual            = NoYes::Yes;
    numRef.WizardAllowChangeDown   = NoYes::No;
    numRef.WizardAllowChangeUp     = NoYes::No;
    numRef.sortField               = 20;
    this.create(numRef);


Which you will copy and modify the copy esp. for the dataTypeId and the help, probably.
Then, you will find a new line in the inventory parameters, tab page number sequences. Setup the new number sequence there.

You will also add a method to table InventParameters, similar to method numRefItemId.

To get a new number from the number sequence, do something like the following:
newItemId = NumberSeq::newGetNum(InventParameters::numRefItemId()).num();

I will be offline for the rest of the afternoon but I'll try and check in in a few hours again, tomorrow morning latest!
0
 
Marius0188Author Commented:
Thanks for the quick reply.

The "NumberSeqReference_Inventory" does not exist underneath the classes group. I will be working on the sales module. Which class should I use then?
0
 
Marius0188Author Commented:
Ooh, my mistake.
I was looking for "NumberSequence_Inventory" and not "NumberSeqReference_Inventory" as your example explained.


Ok let me give it a try.

0
 
Marius0188Author Commented:
Ok I found the new line in the Sales Orders parameter tab page number sequence.

I have  actually add the following method for my new table, nearly similar to the example found in InventParameters:

server static NumberSequenceReference numRefItemId()
{
    return NumberSeqReference::findReference(typeId2ExtendedTypeId(typeid(MasterBOLId)));
}


How can I test my number sequence?
Cause when adding a new line to the table the number sequence do not populate.

Thanks.
0
 
AgrippineCommented:
Just to test the numbersequence, try something like the following:
newItemId = NumberSeq::newGetNum(InventParameters::numRefItemId()).num();


In case you want to use it properly in a form, you might have a look at the InventQuarantineOrder form - it's the simplest example I could find.
Search for numberSeq in the form, you will find that it is used in the form datasources create, delete, write, validateWrite and linkActive methods as well as some methods on the form itself.

Supposing you want something similar - a new form, add a line, its primaryKey should be filled with a value from your numberSequence - than this is the place to copy from!

0
 
Marius0188Author Commented:
I have the following test code in a Job but it prints a nothing.
Any suggestions, please?


static void numSeq(Args _args)
{
    MasterBOLId     newItemId;
    ;
 
    newItemId = NumberSeq::newGetNum(InventParameters::numRefItemId()).num();
    print newItemId;
    pause;
 
}

Open in new window

0
 
Marius0188Author Commented:
Sorry, that is wrong.
This is what I did:
static void numSeq(Args _args)
{
    MasterBOLId     newItemId;
    ;
 
    newItemId = NumberSeq::newGetNum(BOLJournal::numRefItemId()).num();
    print newItemId;
    pause;
 
}

Open in new window

0
 
Marius0188Author Commented:
I am a little confused.
I have added a new method on the new table, BOLJournal, that I've created.
This is the method:

server static NumberSequenceReference numRefItemId()
{
    return NumberSeqReference::findReference(typeId2ExtendedTypeId(typeid(MasterBOLId)));
}




Then in the "NumberSeqReference_SalesOrder" class in "LoadModule" method I've added the following code at near the bottom of this method:

//***MvT*** Master Bill of Lading Number Sequence - BOLId
NumRef.DataTypeId              = typeid2extendedtypeid(typeid(MasterBOLID));
NumRef.ReferenceHelp           = literalStr("Master Bill Of Lading Number Sequence");
NumRef.ReferenceLabel          = literalStr("Master BOL No");
NumRef.WizardContinuous        = false;
NumRef.WizardAllowChangeDown   = NoYes::No;
NumRef.WizardAllowChangeUp     = NoYes::No;
NumRef.WizardManual            = NoYes::No;
NumRef.SortField               = 16;

this.Create(NumRef);



Then in the Sales Order parameters, number sequence tab, I've found the new line and assigned it to the number sequence.

What am I doing wrong here?

Thanks :)
0
 
AgrippineCommented:
Well, it looks good to me ...

What happens when you debug the code in the job?
Does
   NumberSeqReference::findReference(typeId2ExtendedTypeId(typeid(MasterBOLId)));
return a proper object?

If yes, what happens in the call to NumberSeq::newGetNum()? Does it run to the end?

If yes, what happens in the call to num()?
0
 
Marius0188Author Commented:
Hi there,

Ok I've found some code on the internet.
This actually returns a number sequence and every time I run the job the number is increased as it should.

Is this code ok to use?
    NumberSequenceTable       numberSequenceTable;
    NumberSeq                 numberSeq;
 
    ;
 
    select NumberSequenceTable
    where (NumberSequenceTable.NumberSequence == 'BOL_01');
    {
        numberSeq = NumberSeq::newGetNumFromCode
        (NumberSequenceTable.NumberSequence,true);
    }
    numberSeq.used();
    print numberSeq.num();
    pause;

Open in new window

0
 
AgrippineCommented:
Hmmm ... I am surprised that that works and the other code does not, because it boils down to the same thing.

For testing, that code may be ok. When using the number sequence in a form as described above (11.04.2008 at 01:02PM CET), you should implement all those methods that you find on similar forms that also use a number sequence. It's important that the number sequence is cleaned up properly etc ...
0

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 10
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now