Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Unanswered

Create a SysODataActionAttributer in data entity and then accessing the data entity to cancel the transfer order shipment in D365 FO

(0) ShareShare
ReportReport
Posted on by 60

Hello Team,

I have a requirement where i need to create a SysODataActionAttribute in a data entity inventtransferorderheaderentity and use that SysODataActionAttribute to cancel the transfer order shipment, I checked we already have it for ship and receive, so i took reference from that and created one for cancellation of transfer order, Sharing the code of triger and also the code of InventTransferOrderEntityMapbelow

Code in inventransferorderheaderentity : -

[SysODataActionAttribute('CancelShipment_CAP', true)]

public void CancelShipment_CAP()
{
InventTransferOrderEntityMap inventTransferOrderEntityMap;
InventTransferOrderEntityMap.CancelShipment_CAP();
}

Code in InventTransferOrderEntityMap : -

[ExtensionOf(mapstr(InventTransferOrderEntityMap))]
internal final class InventTransferOrderEntityMap_CAP_Extension
{
public void CancelShipment_CAP()
{
ttsbegin;
InventTransferMultiShipCancel inventTransferMultiShipCancel = InventTransferMultiShipCancel::construct();
inventTransferMultiShipCancel.runUpdate(this.createInventTransferParmTable());
ttscommit;

}

}

After writing this code i am trying to test it using postman to check if my transfer order is getting cancelled or not, I also checked with debugging the values are passing correclty but after that it is throwing an exception of update has been cancelled.

If any one has done the transfer order shipment cancellation through odata then please help me on this, Waiting for a positive response on the same. 

Thanks

Piyush Sharma

  • piyush02 Profile Picture
    piyush02 60 on at
    RE: Create a SysODataActionAttributer in data entity and then accessing the data entity to cancel the transfer order shipment in D365 FO

    Hello Martin,

    Thanks for your reply, but the thing mentioned by you is not the problem here, i tried the same by using main method InventTransferMultiShipCancel  instead of runupdate method and it worked

  • Martin Dráb Profile Picture
    Martin Dráb 230,962 Most Valuable Professional on at
    RE: Create a SysODataActionAttributer in data entity and then accessing the data entity to cancel the transfer order shipment in D365 FO

    Your answer didn't make clear to me whether you understand your current bug or not. If you do, go and fix it.

    If you don't, let me repeat that you didn't populate inventTransferOrderEntityMap variable, therefore you current code isn't canceling any shipment. You're calling cancellation on an empty buffer, which must fail.

  • piyush02 Profile Picture
    piyush02 60 on at
    RE: Create a SysODataActionAttributer in data entity and then accessing the data entity to cancel the transfer order shipment in D365 FO

    Hi Martin,

    Definitely i have done something wrong that is why i am asking someone, if someone has done the same thing or not, Although thanks for your help

  • Martin Dráb Profile Picture
    Martin Dráb 230,962 Most Valuable Professional on at
    RE: Create a SysODataActionAttributer in data entity and then accessing the data entity to cancel the transfer order shipment in D365 FO

    Do you agree that your current code can't ever work and trying to run it makes no sense? If so, then we can make some progress. First of all, you must use a shipment, because canceling nothing can't work. Then use the debugger to debug your code. First of all, unsure yourself that your attempt to populate the succeeded.

    If you need our help, tell us more than that you got an exception. Tell us what the error message says and which line of code threw the error. Also, show us the relevant code.

  • piyush02 Profile Picture
    piyush02 60 on at
    RE: Create a SysODataActionAttributer in data entity and then accessing the data entity to cancel the transfer order shipment in D365 FO

    Hello Martin,

    Thanks for your reply, I have tried with assigning the value also previously it didnt worked, It stopped the update and throw an exception.

  • Martin Dráb Profile Picture
    Martin Dráb 230,962 Most Valuable Professional on at
    RE: Create a SysODataActionAttributer in data entity and then accessing the data entity to cancel the transfer order shipment in D365 FO

    In general, you can use the debugger to find more about what's happening in code. And you may want to test your code in X++ first before trying to call it from outside.

    But I think I see a problem in your code - you never assign any value to inventTransferOrderEntityMap variable.

    By the way, please use Insert > Code (in the rich-formatting view) to paste source code to this forum. It preserves line indentation, to mention only one benefit.

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,162 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,962 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans