0

help please on this script

The following works but not fully. None of the text: >>>

Is outputted in the email.  Can someone please point out where my error is.

let myPdf := printAndSaveRecord(this, "TASKS");
let myName := "New Task.pdf";
importFile(this, myPdf, myName);
'EMAIL SENT' := true;
let myEmail := userEmail(user());
sendEmail({
    from: userEmail(),
    to: userEmail(),
    cc: " ",
    bcc: " ",
    subject: "A new Task has been added for: " +
    concat('ASSIGNED ENGINEERS'.'ASSIGNED ENGINEER(S)') +
    " " +
    'TASK TITLE',
    html: 'DESCRIPTION OF TASK',
    text: "Att: " + concat('ASSIGNED ENGINEERS'.'ASSIGNED ENGINEER(S)') +
    "
" +
    "
" +
    "Please refer to the attached" +
    "
" +
    "
" +
    "
" +
    "Kind Regards" +
    "
" +
    "
" +
    userName() +
    " " +
    "
" +
    " ",
    attachments: file(this, myName)
}) 

10 replies

null
    • John_Halls
    • 4 mths ago
    • Reported - view

    Hi Alan

    Not sure I can solve the issue for you but I would start by tidying up the code so the the sendEmail() command is easy to understand

    
    let CR := "
    ";
    let myPdf := printAndSaveRecord(this, "TASKS");
    let myName := "New Task.pdf";
    importFile(this, myPdf, myName);
    let emailSubject := "A new Task has been added for: " +
        concat('ASSIGNED ENGINEERS'.'ASSIGNED ENGINEER(S)') + " " + 'TASK TITLE';
    let emailText := "Att: " + concat('ASSIGNED ENGINEERS'.'ASSIGNED ENGINEER(S)') + CR + CR +
        "Please refer to the attached" + CR + CR + CR + "Kind Regards" + CR + CR +
        userName() + " " + CR + " ";
    sendEmail({
        from: userEmail(),
        to: userEmail(),
        cc: " ",
        bcc: " ",
        subject: emailSubject,
        html: 'DESCRIPTION OF TASK',
        text: emailText,
        attachments: file(this, myName)
    });
    'EMAIL SENT' := true
    

    Not sure what happens if both HTML and text are defined. Are both sent, or only one of them?

    Regards John

      • Alan_Cooke
      • 4 mths ago
      • Reported - view

        Thanks for the housekeeping.  I don't need the HTML in fact but with null in place of my field I get an error when sending.

      I did not add the (" ").

      I have html: null

    • John_Halls
    • 4 mths ago
    • Reported - view

    Hmmm, not sure why that would be. Can you post the full snippet of code. 

      • Alan_Cooke
      • 4 mths ago
      • Reported - view

       I have Ninox support on it.  Will keep you posted here with their solution.

    • Andrew_Dickey
    • 4 mths ago
    • Reported - view
     said:
    html: 'DESCRIPTION OF TASK',

    This should read:

    html: "DESCRIPTION OF TASK",

    or if not intending to use the html tag:

    html: "",

    [Note the use of double quotes]...

    Also, either remove your cc and bcc (if not in use) or set them to empty:

    cc: "",

    bcc: "",

    your code has spaces between the quotes.

     

    Kind regards, Andrew

      • John_Halls
      • 4 mths ago
      • Reported - view

       Hi Andrew. I assumed DESCRIPTION OF TASK was a field name.

      • Andrew_Dickey
      • 4 mths ago
      • Reported - view

       you are likely correct. I thought at the time it was equally likely Alan hadn't intended to set a value for "html" param at all, or had intended to use some placeholder text. Just covering as many troubleshooting points as possible. Kind regards, Andrew

      • Andrew_Dickey
      • 4 mths ago
      • Reported - view

       Also if Alan is referencing a field in the manner you have suggested he may need to convert it to html using html:

      html('DESCRIPTION OF TASK'), ( see https://docs.ninox.com/en/script/functions-overview/functions/html)

    • Alan_Cooke
    • 4 mths ago
    • Reported - view

    Hi all - I used Description.... to replace null which did not work.  I do not want any HTML at all so I will use "" with no space.  I tweaked to script for cc and bcc to leave out personal info.

    Will give this a try out as I have not heard from Ninox at all.  They asked for an invite but so far have not accepted it.

    • Alan_Cooke
    • 4 mths ago
    • Reported - view

    Thanks guys this seems to have worked perfectly!!

Content aside

  • Status Answered
  • 4 mths agoLast active
  • 10Replies
  • 67Views
  • 3 Following