web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)
Answered

Use of File::SendFileToUser after afterOperation fails

(0) ShareShare
ReportReport
Posted on by 1

Hi there

I use chain of command to trigger an action after the posting of the packing slip. There's more to the code, but in essence what I do is this:

[ExtensionOf(classStr(SalesFormLetter_PackingSlip))]
final class Class_SalesFormLetter_PackingSlip_Extension
{
protected void afterOperation(

SysOperationExecutionMode _executionMode,
AifAsyncResult _asyncResult)
{

next afterOperation(_executionMode, _asyncResult);
System.Byte[] byteArray = System.Text.Encoding::UTF8.GetBytes("BOOH!");
System.IO.MemoryStream stream = new System.IO.MemoryStream(byteArray);
File::SendFileToUser(stream, "something.txt");
}

}

I would expect this to trigger the download of the file "something.txt", but instead I get the error

"An internal error has occurred. Please contact your system administrator."

I guess triggering a client action like sending a download during the process isn't allowed, but since it's triggered in the afterOperation I'd expect this to work.

Any thoughts?

*This post is locked for comments

I have the same question (0)
  • Martin Dráb Profile Picture
    239,660 Most Valuable Professional on at

    All X++ code in AX 7 runs on server, as there is no rich client (capable of running X++) anymore, so that's not relevant.

    Jos, which execution mode are you using? What happens if you debug your code? Can you get details of the underlying exception?

  • Verified answer
    Jan M. Profile Picture
    3,333 on at

    Hi Jos

    There is an exception on line: br.navigate(downloadUrl, false, false);

    We reported the problem to MS, they confirmed a product bug (#3858852) and will work on a hotfix.

    Regards

    Jan

  • Sujith kumar vutukur Profile Picture
    5 on at

    Hi Jos,

    I think the issue is with executionMode, what is the executionMode value?

    if executionMode == SysOperationExecutionMode::Synchronous,  then it works fine..

    Might be something related to where code runs(client/server) based on execution mode.

    Regards,

    Sujith

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 21

#2
dekion Profile Picture

dekion 4

#2
Virginia99 Profile Picture

Virginia99 4

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans