Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics GP (Archived)

Unable to create the new Item Currency Record

(0) ShareShare
ReportReport
Posted on by 35

GP version 10

System.Web.Services.Protocols.SoapException was unhandled

  Message=A validation exception has occurred.

Validation Errors:

- ItemKey does not exist.

- U of M does not exist for UofMScheduleKey.

- ItemKey does not exist.

- Unable to create the new Item Currency Record

Here is the method I am trying to run:

 

public void updatePricing()

        {

 

            CompanyKey companyKey;

            Context context;

            ItemKey itemKey;

            PriceLevelKey priceLevelKey;

            CurrencyKey currencyKey;

            PricingKey pricingKey;

            Pricing pricing;

            PricingDetail pricingDetail;

            PricingDetailKey pricingDetailKey;

            Quantity toQuantity;

            PricingDetailPrice detailPrice;

            MoneyAmount priceAmount;

            Policy pricingCreatePolicy;

 

            // Create an instance of the web service

            DynamicsGP wsDynamicsGP = new DynamicsGP();

 

            // Be sure the default credentials are used

            wsDynamicsGP.UseDefaultCredentials = true;

 

            // Create a context with which to call the web 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;

            context.CultureName = "en-US";

 

            // Create an item key to identify the item

            itemKey = new ItemKey();

            itemKey.Id = "TESTINVENTORYITEM0005";

 

            // Create a price level key 

            priceLevelKey = new PriceLevelKey();

            priceLevelKey.Id = "RETAIL";

 

            // Create a currency key

            currencyKey = new CurrencyKey();

            currencyKey.ISOCode = "USD";

 

            // Create a pricing key object and populate its key properties

            pricingKey = new PricingKey();

            pricingKey.ItemKey = itemKey;

            pricingKey.PriceLevelKey = priceLevelKey;

            pricingKey.CurrencyKey = currencyKey;

            pricingKey.UofM = "EACH";

 

 

            // Create a price level object

            pricing = new Pricing();

 

            // Populate the pricing object key

            pricing.Key = pricingKey;

 

            // Create a pricing detail object

            pricingDetail = new PricingDetail();

 

            // Create a pricing detail key 

            pricingDetailKey = new PricingDetailKey();

 

            // Populate the pricing detail key with the pricing key

            pricingDetailKey.PricingKey = pricingKey;

 

            // Create a quantity object

            toQuantity = new Quantity();

 

            // Populate the quantity objects value property with the maximum value

            toQuantity.Value = 999999999999M;

 

            // Populate the pricing detail key ToQuantity property

            pricingDetailKey.ToQuantity = toQuantity;

 

            // Populate the pricing detail key 

            pricingDetail.Key = pricingDetailKey;

 

            // Create a pricing detail price object

            detailPrice = new PricingDetailPrice();

 

            // Create a money amount object to specify the price and currency

            priceAmount = new MoneyAmount();

            priceAmount.Value = 5m;

            priceAmount.Currency = "USD";

 

            // Populate the pricing detail price item with the amount object

            detailPrice.Item = priceAmount;

 

            // Populate the pricing detail object's UofMPrice with the pricing detail price object

            pricingDetail.UofMPrice = detailPrice;

 

            // Create an array for the pricing detail objects

            PricingDetail[] pricingDetails = { pricingDetail };

 

            // Add the array of pricing details to the pricing object

            pricing.Details = pricingDetails;

 

            // Get the create policy for price level

            pricingCreatePolicy = wsDynamicsGP.GetPolicyByOperation("CreatePricing", context);

 

            // Create the pricing object

            try

            {

                wsDynamicsGP.CreatePricing(pricing, context, pricingCreatePolicy);

            }

            catch (Exception err)

            {

                throw err;

            }

 

 

*This post is locked for comments

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,387 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans