Skip to main content

Notifications

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

Is It possible to get the filters applied on the request page into the Email

Posted on by Microsoft Employee

When I apply a filter on a report request page  and is it possible to get the same filter while sending the email 

for eg: I have added a custom report action for job ordrer confitmation  on the job card and I have a custom email function  to send the job order confirmation ,  so what i planning is to get the filter that i applied in the report request page to the email sending attachment with the same filtered data . is it posssible !! I Have tried with adding a request page before sending a email and its working but now iam trying to get the filters as same as preview of the report ..is it possible , to add the preview option to the new request page any help will be great, Thanks in advance.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Is It possible to get the filters applied on the request page into the Email

    Hi, yzhums  I was taking reference from your blog

    https://yzhums.com/7200/ . Is it possible to get the same filters applied in the request page in to our new added request page and add the preview option

     XmlParameters := Report.RunRequestPage(50114, PageParameter); by this

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Is It possible to get the filters applied on the request page into the Email

    Its a custom Email send function

     JobL.Reset();
                        JobL.SetRange("No.", Rec."No.");
                        if JobL.FindFirst() then begin
                            ReportSelections.Reset();
                            ReportSelections.SetRange(Usage, "Report Selection Usage"::JS);
                            if ReportSelections.FindFirst() then begin
                                Customer.Reset();
                                Customer.SetRange("No.", Rec."Bill-to Customer No.");
                                if Customer.FindFirst() then begin
                                    Recipients.Add(Customer."E-Mail");
                                    if Recipients.Count <> 0 then begin
                                        XmlParameters := report.RunRequestPage(50114);
                                        if (XmlParameters <> '') then begin
                                            Message('xmlparameter%1', XmlParameters);
                                            TempBlob.CreateOutStream(OutS);
                                            RecRef.GetTable(JobL);
                                            Report.SaveAs(ReportSelections."Report ID", XmlParameters, ReportFormat::Pdf, outs, RecRef);
                                            TempBlob.CreateInStream(InS);
                                            AttachmentTextL := AttachmentLbl;
                                            SPCSetFileName(AttachmentTextL, Rec);
                                            Attachment := StrSubstNo(AttachmentTextL, Rec."No.");
                                            Subject := StrSubstNo(SubjectLbL, Rec."No.");
                                            EmailMsgL.Create(Recipients, Subject, '', true);
                                            EmailMsgL.AddAttachment(Attachment, 'application/pdf', InS);
                                            EmailL.OpenInEditor(EmailMsgL, Enum::"Email Scenario"::JobShipment);
                                     

  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,091 Super User 2024 Season 1 on at
    RE: Is It possible to get the filters applied on the request page into the Email

    As per above code, if there is nothing generated in the report with Saveas function no code will run, is that your query or something else?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Is It possible to get the filters applied on the request page into the Email

     if Customer.FindFirst() then begin
                                    Recipients.Add(Customer."E-Mail");
                                    if Recipients.Count <> 0 then begin
                                        TempBlob.CreateOutStream(OutS);
                                        RecRef.GetTable(JobL);
                                        XmlParameters := Report.RunRequestPage(50114);
                                        if not Report.SaveAs(50114, XmlParameters, ReportFormat::Pdf, outs, RecRef) then begin
                                            TempBlob.CreateInStream(InS);
                                            AttachmentTextL := AttachmentLbl;
                                            SPCSetFileName(AttachmentTextL, Rec);
                                            Attachment := StrSubstNo(AttachmentTextL, Rec."No.");
                                            Subject := StrSubstNo(SubjectLbL, Rec."No.");
                                            EmailMsgL.Create(Recipients, Subject, '', true);
                                            EmailMsgL.AddAttachment(Attachment, 'application/pdf', InS);
                                            EmailL.OpenInEditor(EmailMsgL, Enum::"Email Scenario"::JobShipment);
                                        end;
                                    end;
                                end;
                            End;

    Now the email window is not getting open,where i went wrong

  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,091 Super User 2024 Season 1 on at
    RE: Is It possible to get the filters applied on the request page into the Email

    Hi

    You have to write your all code like this

    if Report.saveas...... then

    begin

       your all code goes here....

    end;

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Is It possible to get the filters applied on the request page into the Email

    Hi, Thank you for the support, but still its proceeding,

    pastedimage1675671494101v1.png

  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,091 Super User 2024 Season 1 on at
    RE: Is It possible to get the filters applied on the request page into the Email

    Hi,

    you can try that

    if not report.SaveAs() then

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Is It possible to get the filters applied on the request page into the Email

      if Recipients.Count <> 0 then begin
                                        TempBlob.CreateOutStream(OutS);
                                        RecRef.GetTable(JobL);
                                        Report.SaveAs(50114, ReportParameter, ReportFormat::Pdf, outs, RecRef);
                                        ReportParameter := '';
                                        ReportParameter := Report.RunRequestPage(50114);
                                        TempBlob.CreateInStream(InS);
                                        AttachmentTextL := AttachmentLbl;
                                        SPCSetFileName(AttachmentTextL, Rec);
                                        Attachment := StrSubstNo(AttachmentTextL, Rec."No.");
                                        Subject := StrSubstNo(SubjectLbL, Rec."No.");
                                        EmailMsgL.Create(Recipients, Subject, '', true);
                                        EmailMsgL.AddAttachment(Attachment, 'application/pdf', InS);

    Thanks for the replies, I have added , Runrequestpage, but when i click on cancel still its proceeding to email, how can i stop that.

  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 73,565 Super User 2024 Season 2 on at
    RE: Is It possible to get the filters applied on the request page into the Email

    Hi, just adding to Mohana's reply.

    If some filters on the report request page are variables, maybe you need to manually save it into a Text type field.

    Hope this helps as well.

    Thanks.

    ZHU

  • Suggested answer
    Mohana Yadav Profile Picture
    Mohana Yadav 59,137 Super User 2024 Season 2 on at
    RE: Is It possible to get the filters applied on the request page into the Email

    If I understood correctly then yes, you can store the filters into a text variable using the below line and you can use the text variable in the email or report layout etc.

    AppliedFilter := Recordvariable.GetFilters();

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans