web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

AIF - Creating a product number from a number sequence

(0) ShareShare
ReportReport
Posted on by 295

Hello,

I'm using AIF to import products into AX 2012 using this article as a basis:

https://community.dynamics.com/product/ax/axtechnical/b/axsupchainmang/archive/2011/07/06/product-item-data-management-services.aspx

I'd like to automatically generate a product number using a number sequence instead of explicitly typing each one but the product will not be created if  "DisplayProductNumber" is blank.

Would anyone be able to help me work this out?

Thanks!

*This post is locked for comments

I have the same question (0)
  • Silvano319 Profile Picture
    on at

    I'd like to bump this, I am also curious on the way of performing this task.

  • Ben Cameron Profile Picture
    5 on at

    I think I'm getting close to figuring this one out, but I'm now stumped.  Maybe someone else can build on what I've got or point out what I'm doing wrong...

    Using the information in the following link, I tracked down how to easily get to the number sequence reference being used for product numbers, as well as how to get the next number from a number sequence reference:

    msdn.microsoft.com/.../aa608474.aspx

    Here's what my X++ code looks like:

    [SysEntryPointAttribute(true)]
    public Num getNextProductNumber()
    {
        NumberSeq numberSequence;
                
        numberSequence = NumberSeq::newGetNum(EcoResProductParameters::numRefProductNumber());
       
        return numberSequence.num();
    }

     

    I then used the information in the link below to expose my code via WCF:

    http://technet.microsoft.com/en-us/library/gg844225.aspx

     

    I'm able to connect to the service from C# and call the method, but I'm getting an AIFFault with an error message of "Number selection is canceled".  I'm a newbie on X++ development and not yet familiar with the debugging tools, so I used a crude approach for now of evaluating some variables and stuffing them into a string that I can then view from my C# code.  I basically wanted to make sure that I was getting a reference to the correct number sequence, and I also evaluated a few other properties that I thought might possibly affect my ability to get a new number.  Here's the kludgy code I used for that:

    [SysEntryPointAttribute(true)]
    public str getNextProductNumber()
    {
        str status = "Initializing;";
        NumberSequenceReference numberSequenceReference = null;
        NumberSequenceRange nextNumberUnformatted;
        Num nextNumber;
        str numberSequenceCode;
        str nextNumberUnformattedString;
        str isContinuousString;
        str isManualString;
        str isBlockedString;
       
        try
        {
            status = status + " Getting number sequence reference;";
            numberSequenceReference = EcoResProductParameters::numRefProductNumber();
                   
            numberSequenceCode = numberSequenceReference.numberSequenceTable().NumberSequence;
            status = status + " Number sequence code: " + numberSequenceCode + ";";

            isContinuousString = enum2str(numberSequenceReference.numberSequenceTable().Continuous);
            status = status + " Continuous: " + isContinuousString + ";";
           
            isManualString = enum2str(numberSequenceReference.numberSequenceTable().Manual);
            status = status + " Manual: " + isManualString + ";";
           
            isBlockedString = enum2str(numberSequenceReference.numberSequenceTable().Blocked);
            status = status + " Blocked: " + isBlockedString + ";";       
           
            nextNumberUnformatted = numberSequenceReference.numberSequenceTable().NextRec;
            nextNumberUnformattedString = int2str(nextNumberUnformatted);
            status = status + " Next Number: " + nextNumberUnformattedString + ";";       

            status = status + " Getting next number;";
            nextNumber = NumberSeq::newGetNum(numberSequenceReference).num();   
            status = status + " Number successfully retrieved;";
        }
        catch
        {
            status = status + "Exception";
        }

        return status;
    }

    The return value I get from that is:
    "Initializing; Getting number sequence reference; Number sequence code: Prod_6; Continuous: Yes; Manual: No; Blocked: No; Next Number: 284; Getting next number;Exception"

    Based on what I see in the UI, everything looks like what I would expect (number sequence code and the other properties).  I have no clue where to look next.  Any ideas?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans