Share via


CreatePayablesCreditMemo

Description

This method creates a new payables credit memo document.

Parameters

Parameter

Type

Description

payablesCreditMemo

PayablesCreditMemo

The payables credit memo document being created.

context

Context

Specifies information about how the method will be called.

policy

Policy

Specifies the set of behaviors and behavior options to be applied during the operation.

Interfaces

  • Dynamics GP
  • Purchasing

Examples

The following C# example creates a new payables credit memo document with the key "00000000000001950". The example demonstrates setting the document's batch key, vendor key, vendor document number, and purchases amount properties. All other properties use default values.

Cc508585.LegacyEndpoint(en-us,MSDN.10).gif** Legacy endpoint**

using System;
using System.Collections.Generic;
using System.Text;
using DynamicsGPWebServiceSample.DynamicsGPService;

namespace DynamicsGPWebServiceSample
{
    class Program
    {
        static void Main(string[] args)
        {
            CompanyKey companyKey;
            Context context;
            PayablesDocumentKey creditMemoKey;
            BatchKey batchKey;
            VendorKey vendorKey;
            PayablesCreditMemo payablesCreditMemo;
            Policy payablesCreditMemoCreatePolicy;

            // Create an instance of the service
            DynamicsGP wsDynamicsGP = new DynamicsGP();

            // Be sure the default credentials are used
            wsDynamicsGP.UseDefaultCredentials = true;

            // Create a context with which to call the service
            context = new Context();

            // Specify which company to use (sample company)
            companyKey = new CompanyKey();
            companyKey.Id = (-1);

            // Set up the context object
            context.OrganizationKey = (OrganizationKey)companyKey;

            // Create a payables document key object to identify the payables credit memo
            creditMemoKey = new PayablesDocumentKey();
            creditMemoKey.Id = "00000000000001950";

            // Create a batch key
            batchKey = new BatchKey();
            batchKey.Id = "PAYABLES BATCH";

            // Create a vendor key
            vendorKey = new VendorKey();
            vendorKey.Id = "ADVANCED0001";

            // Create a money amount object for the transaction
            MoneyAmount creditAmount = new MoneyAmount();
            creditAmount.Currency = "USD";
            creditAmount.Value = 560m;

            // Create a payables credit memo object
            payablesCreditMemo = new PayablesCreditMemo();

            // Populate the payables credit memo properties
            payablesCreditMemo.Key = creditMemoKey;
            payablesCreditMemo.BatchKey = batchKey;
            payablesCreditMemo.VendorKey = vendorKey;
            payablesCreditMemo.VendorDocumentNumber = "DOCUMENT 40";
            payablesCreditMemo.PurchasesAmount = creditAmount;

            // Get the create policy for payables credit memos
            payablesCreditMemoCreatePolicy = wsDynamicsGP.GetPolicyByOperation(
            "CreatePayablesCreditMemo", context);

            // Create the payables credit memo
            wsDynamicsGP.CreatePayablesCreditMemo(payablesCreditMemo,
            context, payablesCreditMemoCreatePolicy);
        }
    }
}

Cc508585.NativeEndpoint(en-us,MSDN.10).gif** Native endpoint **

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using DynamicsGPWebServiceSample.DynamicsGPService;

namespace DynamicsGPWebServiceSample
{
    class Program
    {
        static void Main(string[] args)
        {
            CompanyKey companyKey;
            Context context;
            PayablesDocumentKey creditMemoKey;
            BatchKey batchKey;
            VendorKey vendorKey;
            PayablesCreditMemo payablesCreditMemo;
            Policy payablesCreditMemoCreatePolicy;

            // Create an instance of the service
            DynamicsGPClient wsDynamicsGP = new DynamicsGPClient();

            // Create a context with which to call the service
            context = new Context();

            // Specify which company to use (sample company)
            companyKey = new CompanyKey();
            companyKey.Id = (-1);

            // Set up the context object
            context.OrganizationKey = (OrganizationKey)companyKey;

            // Create a payables document key object to identify the payables credit memo
            creditMemoKey = new PayablesDocumentKey();
            creditMemoKey.Id = "00000000000001950";

            // Create a batch key
            batchKey = new BatchKey();
            batchKey.Id = "PAYABLES BATCH";

            // Create a vendor key
            vendorKey = new VendorKey();
            vendorKey.Id = "ADVANCED0001";

            // Create a money amount object for the transaction
            MoneyAmount creditAmount = new MoneyAmount();
            creditAmount.Currency = "USD";
            creditAmount.Value = 560m;

            // Create a payables credit memo object
            payablesCreditMemo = new PayablesCreditMemo();

            // Populate the payables credit memo properties
            payablesCreditMemo.Key = creditMemoKey;
            payablesCreditMemo.BatchKey = batchKey;
            payablesCreditMemo.VendorKey = vendorKey;
            payablesCreditMemo.VendorDocumentNumber = "DOCUMENT 40";
            payablesCreditMemo.PurchasesAmount = creditAmount;

            // Get the create policy for payables credit memos
            payablesCreditMemoCreatePolicy = wsDynamicsGP.GetPolicyByOperation(
            "CreatePayablesCreditMemo", context);

            // Create the payables credit memo
            wsDynamicsGP.CreatePayablesCreditMemo(payablesCreditMemo,
            context, payablesCreditMemoCreatePolicy);

            // Close the service
            if(wsDynamicsGP.State != CommunicationState.Faulted)
            {
                wsDynamicsGP.Close();
            }
        }
    }
}