tomekc
tomekc

Reputation: 44

OData action in data entity for table without natural key

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.

Upvotes: 0

Views: 443

Answers (0)

Related Questions