
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:
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.
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 :
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 :
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 :
Body (the newlines are important, do not remove them) :
--batch_AAA123Content-Type: multipart/mixed;boundary=changeset_BBB456--changeset_BBB456Content-Type: application/httpContent-Transfer-Encoding:binaryPATCH 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.1Content-ID: 1Content-Type: application/json{"MinimumOnHandInventoryQuantity": 10}--changeset_BBB456----batch_AAA123--