Solved

MS Dynamics AX 2009 :: Number Sequence for New Document

Posted on 2008-10-28
17
2,305 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
uuuh, sorry.
HTH was short for "hope this helps" ... :-)

Could you tell me where you are stuck?

Regards,
agrippine
0
 

Author Comment

by:Marius0188
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

Author Comment

by:Marius0188
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

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…
On Sep 22nd 2014 Microsoft released Update Rollup 1 for Microsoft Dynamics CRM 2013 Service Pack 1 and back in July Update Rollup 3 was released.  So we now have:   Update Rollup 1Update Rollup 2Update Rollup 3Service Pack 1Update Rollup 1 for S…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

763 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

10 Experts available now in Live!

Get 1:1 Help Now