Solved

MS Dynamics AX 2009 :: Number Sequence for New Document

Posted on 2008-10-28
17
2,308 Views
Last Modified: 2009-09-30
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
Comment
Question by:Marius0188
  • 10
  • 6
17 Comments
 

Author Comment

by:Marius0188
ID: 22822884
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
 
LVL 5

Accepted Solution

by:
Agrippine earned 500 total points
ID: 22829317
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
 

Author Comment

by:Marius0188
ID: 22866408
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
 
LVL 5

Expert Comment

by:Agrippine
ID: 22866426
uuuh, sorry.
HTH was short for "hope this helps" ... :-)

Could you tell me where you are stuck?

Regards,
agrippine
0
 

Author Comment

by:Marius0188
ID: 22866548
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
 
LVL 5

Assisted Solution

by:Agrippine
Agrippine earned 500 total points
ID: 22866948
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
 

Author Comment

by:Marius0188
ID: 22866991
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
 

Author Comment

by:Marius0188
ID: 22866995
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:Marius0188
ID: 22874230
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
 
LVL 5

Expert Comment

by:Agrippine
ID: 22875380
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
 

Author Comment

by:Marius0188
ID: 22875536
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
 

Author Comment

by:Marius0188
ID: 22875552
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
 

Author Comment

by:Marius0188
ID: 22875568
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
 
LVL 5

Expert Comment

by:Agrippine
ID: 22876403
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
 

Author Comment

by:Marius0188
ID: 22883667
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
 
LVL 5

Expert Comment

by:Agrippine
ID: 22883740
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a walkthrough guide I wrote whilst upgrading my on-premise MS Dynamics CRM 3.0 deployment to 4.0. This covers the actual installation of the product to a working level for my system, I ran into a lot of issues that the steps below fixed so h…
Automatically creating a Trello card using data from a Microsoft Dynamics CRM record turned out to be an easy project that yielded great results.  Here's how I did this for an internal team at General Code.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now