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

Community site session details

Session Id :
Supply chain | Supply Chain Management, Commerce
Unanswered

How to update ItemCoverageSettingsV2 in OData or X++?

(1) ShareShare
ReportReport
Posted on by 39

ItemCoverageSettingsV2 is an entity exposed through OData in F&O. But it requires so many keys in the odata patch syntax that the URL length exceeds what IIS allows. This is a known problem with a well-documented registry tweak to solve it. Amazingly, Microsoft refuses to allow this reg tweak on F&O production servers (or so they have told our F&O client). For example, here is what an odata patch looks like for ItemCoverageSettingsV2:

mysandbox-aos.axcloud.dynamics.com/.../ItemCoverageSettingsV2(dataAreaId='usmf',ItemNumber='M0001',CoverageWarehouseLocationId='',CoverageItemBatchNumber='',CoverageProductColorId='',CoverageProductSizeId='',CoverageProductStyleId='',CoverageProductVersionId='',CoverageWarehouseId='11',CoverageItemSerialNumber='',CoverageSiteId='1',CoverageInventoryStatusId='',CoverageProductConfigurationId='')

That URL exceeds IIS's allowable pre-querystring length. The reg tweak is easy and works perfectly, as stated above, but apparently it's not allowed. So I'm trying to instead build a function on our existing web service endpoint in F&O that simply updates ItemCoverageSettingsV2 and changes a few values in an existing record. Pretty simple in concept. The sketchy beginnings of my function look like this:

[SysEntryPointAttribute(true)]
public void setItemCoverageSettingsV2(
str dataAreaId,
str itemNumber,
str coverageWarehouseLocationId,
str coverageItemBatchNumber,
str coverageProductColorId,
str coverageProductSizeId,
str coverageProductStyleId,
str coverageProductVersionId,
str coverageWarehouseId,
str coverageItemSerialNumber,
str coverageSiteId,
str coverageInventoryStatusId,
str coverageProductConfigurationId)
{
// entity (as it is exposed through OData): ItemCoverageSettingsV2

ReqItemCoverageSettingsV2Entity reqItemCoverageSettingsV2Entity;

// How to lookup matching record for update??

reqItemCoverageSettingsV2Entity.selectForUpdate(); // ???
// reqItemCoverageSettingsV2Entity.selectRefRecord(???);

//reqItemCoverageSettingsV2Entity.DataAreaId = dataAreaId; // not allowed - readonly property
reqItemCoverageSettingsV2Entity.ItemNumber = itemNumber;
reqItemCoverageSettingsV2Entity.CoverageWarehouseLocationId = coverageWarehouseLocationId;
reqItemCoverageSettingsV2Entity.CoverageItemBatchNumber = coverageItemBatchNumber;
reqItemCoverageSettingsV2Entity.CoverageProductColorId = coverageProductColorId;
reqItemCoverageSettingsV2Entity.CoverageProductSizeId = coverageProductSizeId;
reqItemCoverageSettingsV2Entity.CoverageProductStyleId = coverageProductStyleId;
reqItemCoverageSettingsV2Entity.CoverageProductVersionId = coverageProductVersionId;
reqItemCoverageSettingsV2Entity.CoverageWarehouseId = coverageWarehouseId;
reqItemCoverageSettingsV2Entity.CoverageItemSerialNumber = coverageItemSerialNumber;
reqItemCoverageSettingsV2Entity.CoverageSiteId = coverageSiteId;
reqItemCoverageSettingsV2Entity.CoverageInventoryStatusId = coverageInventoryStatusId;
reqItemCoverageSettingsV2Entity.CoverageProductConfigurationId = coverageProductConfigurationId;

reqItemCoverageSettingsV2Entity.setFieldValue("MaximumOnHandInventoryQuantity", 1500);
reqItemCoverageSettingsV2Entity.update();
}

You can see that I am setting all those properties/attributes. I'm not sure that's correct. What I'm really trying to do is find a matching record based on all those values. And then I want to actually modify the value of MaximumOnHandInventoryQuantity for that single matching record.

I am missing 2 pieces:

- How do I get a handle to the ItemCoverageSettingsV2 record (based on the params being passed in I should be able to match exactly 1 record), so I can then update a few of the properties/attributes?

- After a few props are set, how do I initiate the save correctly?

Is there some alternative way in OData that would allow me to update/PATCH a record without running into the IIS limitation and without tweaking the registry? This would be much preferred over the custom X++ approach, but I would be happy with either.

Thanks in advance for any help.

I have the same question (0)
  • JuniorD Profile Picture
    38 on at
    RE: How to update ItemCoverageSettingsV2 in OData or X++?

    Hello,

    We had exactly the same issue last week and found dirty workaround to update this entity using OData.

    Just like you said, the URL is too long so simple OData calls such as :

    • GET /data/ItemCoverageSettingsV2(dataAreaId='DA01',ItemNumber='I1234',CoverageWarehouseLocationId='',CoverageItemBatchNumber='',CoverageProductColorId='',CoverageProductSizeId='',CoverageProductStyleId='',CoverageProductVersionId='V01',CoverageItemSerialNumber='',CoverageSiteId='S01',CoverageWarehouseId='W0001'CoverageInventoryStatusId='',CoverageProductConfigurationId='')
    • PATCH /data/ItemCoverageSettingsV2(dataAreaId='DA01',ItemNumber='I1234',CoverageWarehouseLocationId='',CoverageItemBatchNumber='',CoverageProductColorId='',CoverageProductSizeId='',CoverageProductStyleId='',CoverageProductVersionId='V01',CoverageItemSerialNumber='',CoverageSiteId='S01',CoverageWarehouseId='W0001'CoverageInventoryStatusId='',CoverageProductConfigurationId='')

    End in HTTP 400 errors "The request URL is invalid".

    For the GET, you can use "$filter" instead of using the "get by key" syntax :

    • /data/ItemCoverageSettingsV2?$filter=dataAreaId eq 'DA01' and ItemNumber eq 'I1234' and CoverageWarehouseId eq 'W0001'

    For the PATCH request, you can use a batch request like mentioned in this website. To make it work for our F&O environment, we had to tweak the batch request a little bit (encode the URL to escape special chars). Here's our final working version (to change the MinimumOnHandInventoryQuantity value):

    PATCH /data/$batch

    Headers :

    • Content-Type: multipart/mixed;boundary=batch_AAA123

    Body (the newlines are important, do not remove them) :

    --batch_AAA123
    Content-Type: multipart/mixed;boundary=changeset_BBB456

    --changeset_BBB456
    Content-Type: application/http
    Content-Transfer-Encoding:binary

    PATCH ItemCoverageSettingsV2(dataAreaId%3D'DA01'%2CItemNumber%3D'I1234'%2CCoverageWarehouseLocationId%3D''%2CCoverageItemBatchNumber%3D''%2CCoverageProductColorId%3D''%2CCoverageProductSizeId%3D''%2CCoverageProductStyleId%3D''%2CCoverageProductVersionId%3D'V01'%2CCoverageWarehouseId%3D'W0001'%2CCoverageItemSerialNumber%3D''%2CCoverageSiteId%3D'S01'%2CCoverageInventoryStatusId%3D''%2CCoverageProductConfigurationId%3D'')?cross-company=true HTTP/1.1
    Content-ID: 1
    Content-Type: application/json

    {
        "MinimumOnHandInventoryQuantity": 10
    }
    --changeset_BBB456--
    --batch_AAA123--

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Supply chain | Supply Chain Management, Commerce

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 860

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 264 Super User 2025 Season 2

#3
Sagar Suman Profile Picture

Sagar Suman 238 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans