Saturday, April 14, 2012

Next Document Number Web Service using eConnect

Below is sample code for creating custom Web Service using eConnect for Next Document Number.




using Microsoft.Dynamics.GP.eConnect;





[WebMethod]

public string NextSopDocumentNumber(string TransactionType, string salesDocID)

{

GetNextDocNumbers sopTransNumber = new GetNextDocNumbers();

string nextTransactionNumber = string.Empty;

try

{

///string sConnectionString = ConfigurationManager.ConnectionStrings["GpeConnectConnectionString"].ToString();

string sConnectionString = ="server=YourServerName;database=YourDatabaseName;Integrated Security=SSPI;persist security info=False

switch (TransactionType)

{

case "SalesQuote":

nextTransactionNumber = sopTransNumber.GetNextSOPNumber(IncrementDecrement.Increment, salesDocID, SopType.SOPQuote, sConnectionString);

break;



case "SalesOrder":

nextTransactionNumber = sopTransNumber.GetNextSOPNumber(IncrementDecrement.Increment, salesDocID, SopType.SOPOrder, sConnectionString);

break;



case "SalesInvoice":

nextTransactionNumber = sopTransNumber.GetNextSOPNumber(IncrementDecrement.Increment, salesDocID, SopType.SOPInvoice, sConnectionString);

break;



case "SalesReturn":

nextTransactionNumber = sopTransNumber.GetNextSOPNumber(IncrementDecrement.Increment, salesDocID, SopType.SOPReturn, sConnectionString);

break;



case "SalesBackOrder":

nextTransactionNumber = sopTransNumber.GetNextSOPNumber(IncrementDecrement.Increment, salesDocID, SopType.SOPBackOrder, sConnectionString);

break;



}



return nextTransactionNumber;

}

catch (Exception ex)

{// If an error occurs, diplay the error information to the user

throw ex;

}

finally

{

sopTransNumber.Dispose();

}
}



Below are eConnect schemas to get other transaction type Next Doucment Number.
http://msdn.microsoft.com/en-us/library/ff623613.aspx



To Rollback Transactions Number:

 

             [WebMethod]

        public void RollBackMyDocumentNumber(string strTransactionType, string strDocNumber)

        {

           DocumentRollback TransRollback = new DocumentRollback();

 

           string sConnectionString = ConfigurationManager.ConnectionStrings["GpeConnectConnectionString"].ToString();

             

            try

            {

                switch (strTransactionType)

                {

                        case "SOP":

                                    TransRollback .Add(TransactionType.SOP, strDocNumber);

                                    break;

                    case "Adjustment": //Adjustment

                        TransRollback.Add(TransactionType.IVTrans, strDocNumber);

                        break;

                    case "IVTransfer":

                        TransRollback.Add(TransactionType.IVTransfer, strDocNumber);

                        break;

                    case "POPReceipt":

                        TransRollback.Add(TransactionType.POPReceipt, strDocNumber);

                        break;

                }

               

            }

            catch (Exception ex)

            {// If an error occurs, diplay the error information to the user

                throw ex;

            }

            finally

            {

                TransRollback.Dispose();

            }
 
Below is more details on RollBackDocument
 

Feel free to email me if you need any further assistance or please share your code for same.

Happy coding!!!
Thanks
Sandip


13 comments:

  1. I wants to thank for the wonderful read because of the informative information and sharing the thoughts to us....

    ReplyDelete
  2. HI, is there any eConnect 10.0 schema or WS to enter Sales Invoices entry to GP. Any help is highly appreciated. Please respond to me in my email n_shrestha@yahoo.com. Thanks.

    ReplyDelete
    Replies
    1. @Shrestha,
      Web Method SalesInvoice is available in Dynamics GP Web Service. Here is link http://msdn.microsoft.com/en-us/library/cc508459

      Thanks
      Sandip

      Delete
  3. helpful post!! keep up this sweet stuff
    Also visit my web-site ... RGV Realty

    ReplyDelete
  4. Hi Sandip!

    In this post 'string salesDocID' representing to what?
    And how to get the type of a transaction in c#?
    Plz Help me, I am new to GP.

    ReplyDelete
    Replies
    1. Hi,
      SalesDocID is your sales order type like STDORD.
      TransactionType I differentiate like 'SalesQuote' for Quote, SalesOrder for Order etc
      If you need Next Sales Order Number and your sales order type is 'STDORD' then you need to pass ("SalesOrder","STDORD") to web service.

      My email id is: sandipdjadhav@hotmail.com feel free to email me your code and details I will give my best.

      Thanks
      Sandip

      Delete
  5. This comment has been removed by a blog administrator.

    ReplyDelete
  6. Hello Sandip,

    We are facing problems while setting Bank Deposit Posting we are getting following Error

    Error Number = 7408 Stored Procedure= taBRPostBankDeposits Error Description = The Deposit Number for the Checkbook passed in does not exist to be posted
    Node Identifier Parameters: taBRPostBankDeposits
    CHEKBKID = GENERALCHEKING
    depositnumber = RCPTTEST12
    Related Error Code Parameters for Node : taBRPostBankDeposits
    CHEKBKID = GENERALCHEKING
    depositnumber = RCPTTEST12

    Thanks and Regards,

    Sanjay Parab


    ReplyDelete
  7. Sanjay,
    Can you try not to enter Deposit Number? Do not supply Deposit Number and try to integrate your transaction.

    Feel free to email me on : sandipdjadhav@hotmail.com

    Thanks
    Sandip

    ReplyDelete
  8. HI, Thanks for the code, is there any eConnect or WS to enter an Inventory transfer with Serial-Lot Control
    teddy_gdl@hotmail.com. Thanks.

    ReplyDelete
    Replies
    1. I have just send email to your Hotmail.

      Please let me know if you need any additional information.
      Thanks

      Delete
  9. Very Help full information shared with us keep it up Sandip Jadhav :)
    Dynamics GP Partner in UAE

    ReplyDelete
  10. Hi Sandip,
    I am trying to avoid eConnect in a test.
    How can I get the next IV document number for doing a bin transfer by executing the underlying stored procedures? Which stored procedure should I use and what are the parameters please?
    Thanks

    ReplyDelete