Skip to main content
1-Visitor
September 11, 2015
Question

Scheduled trigger that sends a report or query link in an eMail

  • September 11, 2015
  • 2 replies
  • 3782 views

How can I create a scheduled trigger that sends a report or query link in an eMail at a given time?  Not an email of each item.  Simply an email with a link to a query or report that is sent via a scheduled trigger. Thank you.

    2 replies

    16-Pearl
    September 17, 2015

    Hello Daniel,

    Do you mean the trivial case of just sending a hard-coded link to a report or query?  You could do it with the emailAdvanced.js trigger, specifying the message body to contain a link to the query or trigger in question.

    If that's not what you mean, can you supply a little more context?

    Thanks,

    Kael

    DanR.1-VisitorAuthor
    1-Visitor
    September 18, 2015

    Really?  And what do I use for a Query on the "Query" tab?

    This is NOT trivial!

    I fully understand how to use the emailadvanced.js script.  If it is a rule based trigger it fires when ever that rule is true.  If it is a scheduled trigger it requires a query be selected in the "Query" tab.

    I can't be any more clearer.  Like I stated "How can I create a scheduled trigger that sends a query link (simply a link to the query) in an email at a given time?  Not an eMail of each item."

    16-Pearl
    September 23, 2015

    Hi Daniel,

    Now that I've tried running emailAdvanced.js as a scheduled trigger, I understand your frustration.

    For sending out a static message to a pre-determined list, I would consider sending a message via SMTP from the command line, similar to this article at HowToGeek (Windows with PowerShell).  Use the Task Scheduler to schedule it, as described in this Microsoft KB article.  Unix variants have similar options (mail from the CLI, scheduled tasks).

    If the above isn't an option for you because the Integrity host is locked down by your IT/IS team, then you can try this (which is basically a hack):  Create a scheduled trigger using email.js instead.  Create a query that runs quickly and returns no results (with some rule like AND (Type=<someType>, Type!=<someType>)), and use that as the backing query.  Note that email.js doesn't allow HTML formatted messages.  You'll also need to remove the last if clause in the trigger script, or it won't run since it checks to see if the query returns any results before sending.  You'll probably want to make a new version of email.js for this particular case.

    You could do the same thing with emailAdvanced.js if you really want to send HTML content.  The process would be more or less the same as for email.js, but that particular script will require much more hacking to work.  That sort of hacking is outside of the scope of Support, so I won't suggest opening a case in this instance, but rather suggest that you contact your Account Manager to get Global Services involved, if you don't want to do it internally.  It might be easier to pull the part of emailAdvanced.js which encapsulates the HTML into the message, and paste that into your email.js script.

    Regards,
    Kael

    1-Visitor
    September 25, 2015

    Hi Dan:

    Not sure if following helps:-

    Configure Schedule Trigger

    Take code snippet of few functions from EmailAdvanced.js trigger

    if (eb.getEventContext() == "Schedule")
    {
             log("** Start Schedule Event :" + date);

             var Items = args.getIssues();

               var ReportLink =   "http://{hostname}:{port}/im/runreport?selection={ReportName}&mks.disconnect=true"

               var QueryLink = http://{hostname}:{port}/im/viewissue?query={queryname}

                // Concat Item Or other

               Call to NewEmailFunction(ReportLink,QueryLink)

                  // It may require changes to email function but doable.

    }