通过ODATA API和InventoryMovementJournalHeaders实体将库存运动杂志发布给D365财务和运营

发布于 2025-02-11 08:26:45 字数 1883 浏览 1 评论 0原文

我正在尝试使用ODATA API和库存MovementJournalheaders / InventInVentoryMovementJournalNeaderity在D365中创建库存运动期刊。

我已经设法使用库存库林格纳德(Journalheaders)作为起点进行了计数期刊,但是当我尝试使用intectoryMovementJournalheaders实体提出库存运动期刊时,会出现以下错误:

写入“ intentInVentoryMovementJournalHeaderentity”的表行失败。感染:警告:必须填写现场“期刊”。警告:validateWrite在数据源“ inventJournaltable(inventJournaltable)”中失败。

完整错误消息:

{
  "error": {
    "code": "",
    "message": "An error has occurred.",
    "innererror": {
      "message": "Write failed for table row of type 'InventInventoryMovementJournalHeaderEntity'. Infolog: Warning: Field 'Journal' must be filled in.; Warning: validateWrite failed on data source 'InventJournalTable (InventJournalTable)'.",
      "type": "Microsoft.Dynamics.Platform.Integration.Services.OData.AxODataWriteException",
      "stacktrace": "   at Microsoft.Dynamics.Platform.Integration.Services.OData.Update.UpdateProcessor.CreateEntity_Save(ChangeOperationContext context, ChangeInfo changeInfo)\r\n   at Microsoft.Dynamics.Platform.Integration.Services.OData.Update.UpdateManager.<>c__DisplayClass10_0.<CreateEntity>b__1(ChangeOperationContext context)\r\n   at Microsoft.Dynamics.Platform.Integration.Services.OData.Update.ChangeInfo.ExecuteActionsInCompanyContext(IEnumerable`1 actionList, ChangeOperationContext operationContext)\r\n   at Microsoft.Dynamics.Platform.Integration.Services.OData.Update.ChangeInfo.TrySave(ChangeOperationContext operationContext)\r\n   at Microsoft.Dynamics.Platform.Integration.Services.OData.Update.UpdateManager.SaveChanges()\r\n   at Microsoft.Dynamics.Platform.Integration.Services.OData.AxODataDelegatingHandler.<SaveChangesAsync>d__3.MoveNext()"
    }
  }
}

错误消息中所指的字段“日记”在数据实体或发行日期表中不存在,我不会发送它(我也试图将其发送给一个名为“日记”的字段,但它提出了一个字段错误)。这是Microsoft提供的标准,即开箱即用的数据实体。

有人遇到这个错误 /解决了吗?

I am trying to create an Inventory Movement Journal in D365 using the OData API and the InventoryMovementJournalHeaders / InventInventoryMovementJournalHeaderEntity.

I have managed to do similar for the Counting Journal using InventoryCountingJournalHeaders as the starting point but get the following error when I try to raise an Inventory Movement Journal with InventoryMovementJournalHeaders entity:

Write failed for table row of type 'InventInventoryMovementJournalHeaderEntity'. Infolog: Warning: Field 'Journal' must be filled in.; Warning: validateWrite failed on data source 'InventJournalTable (InventJournalTable)'.

Full error message:

{
  "error": {
    "code": "",
    "message": "An error has occurred.",
    "innererror": {
      "message": "Write failed for table row of type 'InventInventoryMovementJournalHeaderEntity'. Infolog: Warning: Field 'Journal' must be filled in.; Warning: validateWrite failed on data source 'InventJournalTable (InventJournalTable)'.",
      "type": "Microsoft.Dynamics.Platform.Integration.Services.OData.AxODataWriteException",
      "stacktrace": "   at Microsoft.Dynamics.Platform.Integration.Services.OData.Update.UpdateProcessor.CreateEntity_Save(ChangeOperationContext context, ChangeInfo changeInfo)\r\n   at Microsoft.Dynamics.Platform.Integration.Services.OData.Update.UpdateManager.<>c__DisplayClass10_0.<CreateEntity>b__1(ChangeOperationContext context)\r\n   at Microsoft.Dynamics.Platform.Integration.Services.OData.Update.ChangeInfo.ExecuteActionsInCompanyContext(IEnumerable`1 actionList, ChangeOperationContext operationContext)\r\n   at Microsoft.Dynamics.Platform.Integration.Services.OData.Update.ChangeInfo.TrySave(ChangeOperationContext operationContext)\r\n   at Microsoft.Dynamics.Platform.Integration.Services.OData.Update.UpdateManager.SaveChanges()\r\n   at Microsoft.Dynamics.Platform.Integration.Services.OData.AxODataDelegatingHandler.<SaveChangesAsync>d__3.MoveNext()"
    }
  }
}

The field 'Journal' referred to in the error message does not exist in the data entity or the InventJournalTable table and I am not sending it (I have also tried to send it a field called 'Journal' but that raises an error also). This is a standard, out of the box, data entity provided by Microsoft.

Has anyone come across this error / solved it please?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

陈甜 2025-02-18 08:26:45

我能够复制您的问题。在仔细研究了计数和运动期刊的实体之后,事实证明,计数期刊实体确实支持创建新期刊,而无需指定主要自然钥匙的价值,即期刊编号。它使用实体的initvalue方法中的以下代码执行此操作:

public void initValue()
{
    if (!this.skipNumberSequenceCheck())
    {
        NumberSeqRecordFieldHandler::enableNumberSequenceControlForField(
            this, fieldNum(InventInventoryCountingJournalHeaderEntity, JournalNumber), InventParameters::numRefInventJournalId());
    }

    super();
}

移动期刊的实体中缺少此代码。这意味着该实体不支持未指定期刊编号的新期刊的创建。

您可以轻松自定义实体以添加此支持。我在实体的代码扩展中添加了以下代码。之后,我能够使用实体创建新的运动期刊。

[ExtensionOf(tableStr(InventInventoryMovementJournalHeaderEntity))]
final class InventInventoryMovementJournalHeaderEntity_Tutorial_Extension
{
    public void initValue()
    {
        if (!this.skipNumberSequenceCheck())
        {
            NumberSeqRecordFieldHandler::enableNumberSequenceControlForField(
                this, fieldNum(InventInventoryMovementJournalHeaderEntity, JournalNumber), InventParameters::numRefInventJournalId());
        }
        
        next initValue();
    }

}

I'm able to replicate your issue. After a closer look at the entities of both counting and movement journals, turns out that indeed the counting journal entity does support creating a new journal without specifying the value for the primary natural key, the journal number. It does this with the following code in the initValue method of the entity:

public void initValue()
{
    if (!this.skipNumberSequenceCheck())
    {
        NumberSeqRecordFieldHandler::enableNumberSequenceControlForField(
            this, fieldNum(InventInventoryCountingJournalHeaderEntity, JournalNumber), InventParameters::numRefInventJournalId());
    }

    super();
}

This code is missing in the entity for movement journals. This means that the entity does not support creation of new journals without specifying the journal number.

You can easily customize the entity to add this support. I added the following code in a code extension for the entity. Afterwards, I was able to create new movement journals using the entity.

[ExtensionOf(tableStr(InventInventoryMovementJournalHeaderEntity))]
final class InventInventoryMovementJournalHeaderEntity_Tutorial_Extension
{
    public void initValue()
    {
        if (!this.skipNumberSequenceCheck())
        {
            NumberSeqRecordFieldHandler::enableNumberSequenceControlForField(
                this, fieldNum(InventInventoryMovementJournalHeaderEntity, JournalNumber), InventParameters::numRefInventJournalId());
        }
        
        next initValue();
    }

}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文