0

In Dynamics 365 Finance and Operations, I created data entity for WMSOrderTrans table. Let's say it's SalesOrderPickingListLines. I've added EntityKey with two fields: orderId and RecId (the same index exists in the table itself, named OrderIdx). The data entity works without an issue, key fields are in the metadata, I can get a record using data/SalesOrderPickingListLines(dataAreaId='inpl',orderId='myorder',RecId1=myrecordid) The problem is, that now I need to create OData action for it, but it seems that that the key fields are not seen in the action. I am using Power Automate to test it.

I created a function in the entity's class with this code:

[SysODataActionAttribute('SetPickQuantity', true)]
public real setPickQuantity(InventQty _qty)
{
    
    WMSOrderTrans _wmsOrderTrans;

    select firstonly forupdate _wmsOrderTrans
        where _wmsOrderTrans.orderId == this.orderId && _wmsOrderTrans.RecId == this.RecId1;

    // some code to proceed

    return _wmsOrderTrans.Qty;

}

The OData action is seen by Power Automate, but there are no key fields (except Company), so I am unable to perform this action for any record.

Power automate Dynamics FinOps execute action

Usually it works without doing any other steps so that's why I'm here. The only difference with this and my previous work is that the source table (WMSOrderTrans) does not have a natural key, its index is RecId field. But I am not sure if this is the issue here. Any help will be appreciated.

burnsi
  • 6,194
  • 13
  • 17
  • 27
tomekc
  • 44
  • 5
  • 1
    I think the natural key could be the issue - https://stoneridgesoftware.com/dealing-with-the-the-natural-key-for-the-table-was-not-found-error-in-the-dynamics-365-data-entity-wizard/ – Alex Kwitny Jan 31 '23 at 15:10
  • Thanks, @AlexKwitny that's what I think of.. and I created this entity just like it's described in your link. I am just wondering if there are any workarounds for this to get it work with OData actions. – tomekc Feb 01 '23 at 08:39
  • 1
    Take a look at https://learn.microsoft.com/en-us/dynamics365/fin-ops-core/dev-itpro/data-entities/data-entity-wizard-rules too, where the natural key may have additional importance with expanding data from foreign related tables. – Alex Kwitny Feb 01 '23 at 17:34

0 Answers0