to send current form values

sathangaisathangai Member Posts: 25
Hi all,
in my todo card(form no. 5098). i have placed a send mail button.when iam clicking the send mail button...i need to send the current record which i entered in the form fields.
i've created a record datatype for (salesperson/purchaser card table) for picking the email id for the current salspersoncode enterd in the form(5098).plz take a look on the code...

when iam clicking the send mail button the attachment,to,cc..everything works fine..but entire report gets printed.....
i need the current record which i entered in the form(5098) fields to be send to the appropriate salesperson...
or
to send the report filtered with status (not started or in progres.....)
iam a newbie n help me with codes
using nav2009,classic client,sqlserver


IF ("No."<>'') THEN
BEGIN
IF "Salesperson Code" = recsalesper.Code THEN
recsalesper.RESET;
recsalesper.SETRANGE(recsalesper.Code,"Salesperson Code");
IF recsalesper.FIND('-') THEN
BEGIN
// sTo:='aaa@aaa.com';
sCC:='aaa@aaa.com';
sSubject:='sales report';
sMessage:='Hello';
// REPORT.RUNMODAL(REPORT::"Salesperson - To-dos",FALSE);
RptPath:='D:\myreport2.html';
SETFILTER(Status,'Not Started');//rec.setfilter
salperReport.SAVEASHTML(RptPath);

MailSent:=cMail.NewMessage(recsalesper."E-Mail",sCC,sSubject,sMessage,RptPath,TRUE);

IF MailSent THEN
MESSAGE('Mail sent successfully')
ELSE
ERROR('Mail sending failed');
END
END

Name DataType Subtype Length
recsalesper Record Salesperson/Purchaser
sCC Text 30
sSubject Text 30
sMessage Text 30
RptPath Text 30
MailSent Boolean
cMail Codeunit Mail
salperReport Report Salesperson - To-dos

Comments

  • reijermolenaarreijermolenaar Member Posts: 256
    You must add a SETTABLEVIEW command before executing the report:
    recsalesper2 := recsalesper;
    recsalesper2.SETRECFILTER;
    salperReport.SETTABLEVIEW(recsalesper2);
    
    Reijer Molenaar
    Object Manager
  • krikikriki Member, Moderator Posts: 9,110
    [Topic moved from 'NAV 2009' forum to 'NAV/Navision' forum]
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • sathangaisathangai Member Posts: 25
    Thank you reijermolenaar...

    just clarify......

    i have to define recsalesper2 as datatype record and subtype salesper/pur table...
    and where i have to place this code...coz again it not happens..
    thanks..
  • sathangaisathangai Member Posts: 25
    when iam running the form It throws me
    " The salesperson -todo's report does not have a dataitem that uses the table(table13salesperson/pur..) specified in the function settable view"


    IF ("No."<>'') THEN
    BEGIN
    IF "Salesperson Code" = recsalesper.Code THEN
    recsalesper.RESET;
    recsalesper.SETRANGE(recsalesper.Code,"Salesperson Code");
    IF recsalesper.FIND('-') THEN
    BEGIN
    // sTo:='ramkumar@astralconsultants.com';
    sCC:='ramkumar@astralconsultants.com';
    sSubject:='sales report';
    sMessage:='Hello';
    // REPORT.RUNMODAL(REPORT::"Salesperson - To-dos",FALSE);
    RptPath:='D:\myreport2.html';
    SETFILTER(Status,'Not Started');
    salperReport.SAVEASHTML(RptPath);
    recsalesper2 := recsalesper;
    recsalesper2.SETRECFILTER;
    salperReport.SETTABLEVIEW(recsalesper2);

    MailSent:=cMail.NewMessage(recsalesper."E-Mail",sCC,sSubject,sMessage,RptPath,TRUE);

    IF MailSent THEN
    MESSAGE('Mail sent successfully')
    ELSE
    ERROR('Mail sending failed');
    END
    END
  • reijermolenaarreijermolenaar Member Posts: 256
    Ok, I get it.
    Your report has probably the table to-do a first dataitem?

    Then create a local var ToDo of type record table to-do and do the following:
    ToDo := Rec;
    ToDo.SETRECFILTER;
    salperReport.SETTABLEVIEW(ToDo);
    salperReport.SAVEASHTML(RptPath);
    
    Reijer Molenaar
    Object Manager
  • sathangaisathangai Member Posts: 25
    Thanks reijermolenaar..............now it's working.....agian thanks for ur valuble reply ...iam a anewbie and learning....this helps me a lot....
Sign In or Register to comment.