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 SL (Archived)

Report button in transaction screen may render dirty data, need to save first

(0) ShareShare
ReportReport
Posted on by 16

Please help on one customization scenario I can't figure well.

Inside a transaction screen I have a customized Print button. The button launches a ROISRS report that shows the transaction currently open in the screen. The screen itself is CN.SPR.00 which handles payment for contractors. This report has some official weight payment wise.

Some users have been clicking this Print button and rendering the report as a pdf file. In fact, they print the report for the supervisor's signature. A week later they notice the rendered report is different from the registered transaction. The rendered report has some consistency errors (they signed anyway) but the registered transaction is correct. If they reprint the transaction they see it right and consistent. Checking the pdf time signature it says 18:09:42 and the record's lupd_datetime says 18:10:00.

So what happened? In a test environment I checked you can click the Print button before saving the on-screen transaction to the database. So, the ROISRS rendering process sees dirty data.

So, first solution: make a call on Edit_Save on every click of the Print button before launching the report. This does work and the report always render clean data.

Problem: the Edit_Save may fail and the report launches anyway.

This kind of screens do have several business oriented rules to check. The Edit_Save expectedly enforces them all, but has no return value. Hitting the Print button in this case yields a prompt indicating the offending data, but the report comes anyway.

Second solution: make a call on Edit_Save and set up a flag. The flag gets cleared during the OnUpdate events sequence. The report launches only on a cleared flag. This way the report does show only after a successful save. On a failed save, the user does get a prompt with the validation stuff.

Problem: there are times in which there's no changes to save. Even if you call Edit_Save, the OnUpdate events don't trigger, the flag never gets cleared, no validation prompt appears, no report also. So, the Print button is a do-nothing. 

Here I'm stuck now. There should be an obvious way I'm missing. The Print button is an obvious thing. In this kind of system, the reporting engine always works on a separate context, hence you always should save before print.

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Community Member Profile Picture
    on at

    Erich,

    You did not indicate whether the custom form has a grid section or not but I would think the following logic would work:

    Using your flag value as you suggested, start the flag value to allow print when the form is loaded.  If you start a new record or change any of the fields that affect your edits, set the flag to not allow print.  Once the validation completes successfully, set the flag to allow print.  A variation of this would be to start with the Print button enabled and disable it upon a new record or changes to any of the validation fields instead of using your flag.  That way, the print option is only available when you have validated the record.

  • Erich Strelow F Profile Picture
    16 on at

    I did the enable/disable button thing. In fact, most of the enable/disable logic was there already. As you said, the button start enabled viewing an old transaction and starts disabled on a new record. It helps a lot on some key data to disable the button.

    As for the flag, I didn't want to stuff the screen with flag clearing code on every field. What I did is to setup the flag inside the OnUpdate event but on level 0, and clear it on level Finished. That way I get the better results.

    The screen has several customizations, so there are more than one version of the OnUpdate event

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 May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics SL (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans