Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 Community / Forums / Finance forum / X++ code to control Pl...
Finance forum
Suggested answer

X++ code to control Plafond of the Intent Letters tax

Posted on by 71
I need to implement the procedure for posting vendor invoices (both from purchase order and journal) by inserting a pop-up that is enabled when the amount to be deducted from the letter of intent relating to the document being posted is greater than the remaining amount of the letter. 
The pop-up should show the following message: 
/Amount to be deducted from the balance of the letter of intent greater than the remaining amount. Shall we continue?/ 
The pop-up should have two buttons: 
Ok: If used, the system will have to account for the invoice despite the overhang. 
Cancel: If used, the system will cancel the posting. 
I'm new with dynamics, I'm really struggling to find examples and documentation on the internet and I'm stuck in this task. I tried to do an event handler, checking if the remaining amount in the intent letter table is less than 0, but I'm sure my code is not correct. Does anyone has any hint for me? Thank you
  • Suggested answer
    Waed Ayyad Profile Picture
    Waed Ayyad 3,904 on at
    X++ code to control Plafond of the Intent Letters tax
     
    As I understand you want to keep track of your total remaining balance, if yes, I suggest the following:
     
    1-Add a new field (Enum No/Yes) on your table (IntentLetterTable) name it for example: BalanceCheck, by default it will be No.
     
    2- Create batch class to check if your condition is met (if the total remaining amount on the intent letter is less than the amount of the new invoice), if it is met then set the new field (BalanceCheck) to yes. This batch you can schedule it to run every day, every hour, etc.
     
    3- If you want the pop up to appear in certain form, you can check your table for the newly created field if yes then show the message box and add your logic in case the user clicks ok or cancel.
     
     
    Regards,
    Waed Ayyad.
    Please mark this answer as "Verified" if it solved your issue. In order to help others who will face a similar issue in the future
     
     
  • FabFab97 Profile Picture
    FabFab97 71 on at
    X++ code to control Plafond of the Intent Letters tax
    Hi @Waed Ayyad,
    Thank you for your reply, I was lookinf for the way to make my dialog as a pop-up, and this was useful for sure. About my issue, I'll try to explain better.
    My company has a "IntentLetterTable" where are stored the intent letters, and in one field I can see the total amount remaining for a specific transaction or client. When, in another table called "VendParameters" I register a new invoice, If the total remaining amount on the intent letter is less than the amount of the new invoice, the pupUp should appear. 
    For now it doesn't appeat anything, and the total remaining amount already becomes automatically a negative number, so the logic is already there, but it was made by another developer, not me. What I need to add to the logic is just to make the popUp appear, and manage the 2 buttons OK (if I want to keep the logic and display a negative amount) of CANCEL (if I want to stop the process and do not register the invoice). If you wanto some code I can try to send you, but as I wrote, my code is wrong for sure, and the others table and classes were not created by me. Thank you very much if you can help me.
    Fabrizio.
  • Suggested answer
    Waed Ayyad Profile Picture
    Waed Ayyad 3,904 on at
    X++ code to control Plafond of the Intent Letters tax
     
    This code you can use in order to show a pop -up, you can start with it. Also, can give me more details where you will add this pop -up, if you can share your code in order to help you better?
     
     
     DialogButton diagBut;
     str strMessage = "mount to be deducted from the balance of the letter of intent greater than the remaining amount. Shall we continue?/";
     str strTitle = "Your Title";
         ;
     diagBut = Box::yesNo(
      strMessage,
       DialogButton::No, // Initial focus is on the No button.
       strTitle);
     if (diagBut == DialogButton::Yes)
      {
                   // Add your logic
       }
     
    Regards,
    Waed Ayyad
    Please mark this answer as "Verified" if it solved your issue. In order to help others who will face a similar issue in the future
     

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 288,584 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,864 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans