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

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested answer

Event Subscriber Trigger - When an Interaction is created

(0) ShareShare
ReportReport
Posted on by 10

Hi Forum,

I've got a requirement in Business Central where, when an interaction is created - a prompt needs to appear to ask the user if they want to create a Task (to-do).

The event that I can see is:

[EventSubscriber(ObjectType::Page, Page::"Create Interaction", 'OnQueryClosePageEvent', '', true, true)]

Does anybody know how to subscribe to this event only if the page is closed with an "OK", and the interaction is created successfully.    This trigger is being called with the "cancel" button as well.

Best regards,

Andy

I have the same question (0)
  • Suggested answer
    Amit Baru Profile Picture
    3,037 on at
    RE: Event Subscriber Trigger - When an Interaction is created

    Hi,

    Pls use below link for reference of Events use in BC D365

    https://erpconsultors.com/onaftervalidateevent-in-business-central/

    Regards

    Amit Sharma

    www.erpconsultors.com

  • Suggested answer
    Nitin Verma Profile Picture
    21,684 Moderator on at
    RE: Event Subscriber Trigger - When an Interaction is created

    Hi,

    Instead the event you can try Page Extension like below

    pageextension 50100 "Create Intc" extends "Create Interaction"
    {
        trigger OnQueryClosePage(CloseAction: Action): Boolean
        begin
            if (CloseAction = CloseAction::OK) THEN
                Message('YOUR ACTION GOES HERE');
            if (CloseAction = CloseAction::Cancel) THEN
                Message('YOUR ACTION GOES HERE');

        end;
    }
  • Andrew Lees Profile Picture
    10 on at
    RE: Event Subscriber Trigger - When an Interaction is created

    Thanks Amit, I did consider using the table.insert.  But my worries were that this only needs to be called from a user created interaction and that if I put the subscription requirement at this point, all the system created interactions would go through this code as well.

    Andy

  • Andrew Lees Profile Picture
    10 on at
    RE: Event Subscriber Trigger - When an Interaction is created

    Thanks Nitin,

    Excellent suggestion and I've just tried this - but the CloseAction condition didn't fire.  The only thing I can think of is that this page is called using funky temp tables.

    Andy

  • Suggested answer
    Nitin Verma Profile Picture
    21,684 Moderator on at
    RE: Event Subscriber Trigger - When an Interaction is created

    Show me your code. why this is not fire, it does not correspondence what the actual table is

  • Andrew Lees Profile Picture
    10 on at
    RE: Event Subscriber Trigger - When an Interaction is created

    pageextension 50126 CreateIntExt extends "Create Interaction"

    {

       trigger OnQueryClosePage(CloseAction: Action): Boolean

       begin

           if (CloseAction = CloseAction::OK) THEN

               Message('YOUR OK ACTION GOES HERE');

           if (CloseAction = CloseAction::Cancel) THEN

               Message('YOUR CLOSE ACTION GOES HERE');

       end;

    }

  • Andrew Lees Profile Picture
    10 on at
    RE: Event Subscriber Trigger - When an Interaction is created

    Its just a slight variation of yours to test the two actions.

  • Andrew Lees Profile Picture
    10 on at
    RE: Event Subscriber Trigger - When an Interaction is created

    pastedimage1663338158182v1.png

  • Suggested answer
    Nitin Verma Profile Picture
    21,684 Moderator on at
    RE: Event Subscriber Trigger - When an Interaction is created

    Please use below with updated one.

    if (CloseAction = CloseAction::LookupOK) THEN

               Message('YOUR ACTION GOES HERE');

           if (CloseAction = CloseAction::LookupCancel) THEN

               Message('YOUR ACTION GOES Cancel HERE');

  • Suggested answer
    Andrew Lees Profile Picture
    10 on at
    RE: Event Subscriber Trigger - When an Interaction is created

    Worked a treat, thank you for your help Nitin.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
Rishabh Kanaskar Profile Picture

Rishabh Kanaskar 4,237

#2
Nimsara Jayathilaka. Profile Picture

Nimsara Jayathilaka. 3,425

#3
Sumit Singh Profile Picture

Sumit Singh 2,907

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans