Skip to main content

Notifications

Announcements

No record found.

Business Central forum
Suggested answer

Event Subscriber Trigger - When an Interaction is created

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

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

    Your are welcome. good to know it helps you.

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

    Worked a treat, thank you for your help Nitin.

  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,023 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');

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

    pastedimage1663338158182v1.png

  • Andrew Lees Profile Picture
    Andrew Lees 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
    Andrew Lees 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;

    }

  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,023 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
    Andrew Lees 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

  • Andrew Lees Profile Picture
    Andrew Lees 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

  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,023 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;
    }

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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

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

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,537 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,520 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans