Microsoft Developer Network > Forums Home > Commerce Server Forums > Commerce Server 2007 > Getting the Tracking Number From Commerce in the basket
Ask a questionAsk a question
 

AnswerGetting the Tracking Number From Commerce in the basket

  • Thursday, November 09, 2006 10:31 PMPatrick JT Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hello,

    Is it possible to get a TrackingNumber from commerce before I create an order? I want to avoid to create my own Tracking Number system. The API doesn't seem to expose methods to grab the next Tracking Number and I couldn't find a stored procedure. I traced the calls to the DB and it seems to be calling the IdentityCounter table from internally.

    Thanks, Patrick

     

     

Answers

  • Friday, November 10, 2006 12:21 AMVinayak Tadas - MSFT Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Hi Colin,

    You should be able to do the above in one upate statement

    CREATE PROCEDURE [dbo].[RetrieveNextTrackingNumber]
    AS
    BEGIN
          Declare @CurrentId int

                 UPDATE IdentityCounter
                    SET @CurrentId = CurrentId = CurrentId + 1
                    WHERE CounterName = 'PuchaseOrder.TrackingNumber'
                Select @CurrentId
     END

All Replies

  • Thursday, November 09, 2006 10:54 PMColin BowernMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hey Patrick,

    You can assign the tracking number yourself before saving it as an order.  We ended up doing this because CS2007 allocates 5,000 order numbers for each application instance.  If the application pool is reset you jump up to the next block of 5,000.  We noticed this first when unit testing.

    Here's the stored procedure that we use to do this:

    CREATE PROCEDURE [dbo].[RetrieveNextTrackingNumber]
    AS
    BEGIN
          BEGIN TRANSACTION
                UPDATE IdentityCounter
                    SET CurrentId = CurrentId + 1
                    WHERE CounterName = 'PuchaseOrder.TrackingNumber'
               
                SELECT CurrentId
                    FROM IdentityCounter
                    WHERE CounterName = 'PuchaseOrder.TrackingNumber'
          COMMIT TRANSACTION
    END

    Cheers,
    Colin

  • Friday, November 10, 2006 12:21 AMVinayak Tadas - MSFT Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Hi Colin,

    You should be able to do the above in one upate statement

    CREATE PROCEDURE [dbo].[RetrieveNextTrackingNumber]
    AS
    BEGIN
          Declare @CurrentId int

                 UPDATE IdentityCounter
                    SET @CurrentId = CurrentId = CurrentId + 1
                    WHERE CounterName = 'PuchaseOrder.TrackingNumber'
                Select @CurrentId
     END

  • Friday, November 10, 2006 3:14 AMColin BowernMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Vinayak,

    Fantastic, thanks!  I'll add that to our build and share it with the team.

    Cheers,
    Colin

  • Friday, November 10, 2006 2:13 PMPatrick JT Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Thank you both.
  • Friday, November 10, 2006 11:43 PMColin BowernMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    I posted a bit of more depth on the issue on my blog... http://blogs.rockstarguys.com/blogs/colin/archive/2006/11/10/18.aspx

     

  • Thursday, October 29, 2009 3:02 PMJaybuffet Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Colin:

    Your page doesn't exist anymore.  Do you have an updated link?