Skip to main content

Notifications

Announcements

No record found.

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

Code for displaying all interaction log entries for a specific customer

(1) ShareShare
ReportReport
Posted on by 105
I want to write, what I thought would be a simple page what would display all the interaction log entries for a customer, which in turn is for all of the contacts for that customer.  I thought I could build up a filter list of contacts, but the filter will reach the max characters.  Then I thought I would simply /mark/ the records that I want to display, but I don't want to scan every interaction log entry to determine which ones I want to mark.  I tried borrowing some of the code from the /contacts/ off of the customer.
 
Here is what I have right now, I always end up with only the marked records from the last contact, instead of all the contacts in the list;
                trigger OnAction()
                var
                    ContBusRel: Record /Contact Business Relation/;
                    Cont: Record Contact;
                    OfficeContact: Record Contact;
                    OfficeMgt: Codeunit /Office Management/;
                    ConfirmManagement: Codeunit /Confirm Management/;
                    ContactPageID: Integer;
                    InteractionLog: Record /Interaction Log Entry/;
                    ContactFilter: text;
                begin
                    rec.ShowContact();
                    if OfficeMgt.GetContact(OfficeContact, rec./No./) and (OfficeContact.Count = 1) then begin
                        ContactPageID := PAGE::/Contact Card/;
                        PAGE.Run(ContactPageID, OfficeContact);
                    end else begin
                        if rec./No./ = '' then
                            exit;
                        InteractionLog.FilterGroup(-1);
                        ContBusRel.SetCurrentKey(/Link to Table/, /No./);
                        ContBusRel.SetRange(/Link to Table/, ContBusRel./Link to Table/::Customer);
                        ContBusRel.SetRange(/No./, rec./No./);
                        if ContBusRel.FindSet() then begin
                            cont.SetRange(/Company No./, ContBusRel./Contact No./);
                            if cont.FindSet() then
                                repeat
                                    InteractionLog.SetRange(/Contact No./, cont./No./);
                                    if InteractionLog.FindSet() then
                                        repeat
                                            InteractionLog.Mark(true);
                                        until InteractionLog.Next() = 0;
 
                                until cont.next = 0;
                        end;
                        InteractionLog.MarkedOnly(true);
                        InteractionLog.FilterGroup(0);
                        ContactPageID := PAGE::/Interaction Log Entries/;
                        PAGE.Run(ContactPageID, InteractionLog);
 
                    end;
                end;
 
 
  • Suggested answer
    gdrenteria Profile Picture
    gdrenteria 12,920 Most Valuable Professional on at
    Code for displaying all interaction log entries for a specific customer
    Hi
    If you want to display the records on a page, I would think you should mark them up using a temporary record set or another option.
    The theory indicates that cross-column search (FilterGroup(-1)) does not work on UI side and cannot be used to add default filter in OnOpenPage trigger.
    Best Regards
    Gerardo
  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 75,595 Super User 2024 Season 2 on at
    Code for displaying all interaction log entries for a specific customer
    Hi, you need to get the all filters and then pass them to the variables of the table when the page is opened.
    Hope the following helps.
    How to get a filter for the selected records on any page (For example, ‘1..3|6’)
     
     
    Thanks.
    ZHU

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

Congratulations 2024 Spotlight Honorees!

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December!

Congratulations to our December super stars! 🥳

Get Started Blogging in the Community

Hosted or syndicated blogging is available! ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,642 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,371 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans