Send email with pdf attachment by button So I...

(Keith Winston) #1

Send email with pdf attachment by button So I finally got a report with pdf attachment with pictures working pretty well (thanks for all the help!). Right now it’s just a report on a schedule, with the template start statement <<Start:SELECT(Properties[BlitzKey], true, true)>> and “With These Rows” value in the report set to “only send once”

I need a very similar “report” (probably will be a workflow actually) to be sent by a button in a slideshow. I think that button has to modify a field, which then will actually trigger the workflow. At first this seemed sort of stupid, but then I realized if I used the button/action to increment a “reports sent” column, that’s useful info. If I set up the workflow with a “If this is true” condition something like [_ThisRow_Before].[ReportsSent]<[_ThisRow_After].[ReportsSent], then other row changes won’t trigger the workflow.

Also, I only want to send the current row, which I think entails changing my condition statement for the workflow to a slice including only _ThisRow… I haven’t worked with slices yet.

I’m sort of thinking out loud here, and hoping to check my thinking: is this a reasonable way to go about this? Have I missed something? I haven’t worked with actions or workflows yet either (it’s amazing how far you can get in this platform without knowing anything), so perhaps I’m being unduly cautious. Thanks!

(Keith Winston) #2

In conjunction with all this, I’ll say that the Expression Builder doesn’t help with _ThisRow or the before/after question. I’m still searching through your documentation, page by page, trying to find that reference.

(Philip Garrett) #3


See topic “Sending Email When a Row is Updated to Have Specific Values” in this article - Triggering Email, SMS, or Notifications from the App

Triggering Email, SMS, or Notifications from the App

(Keith Winston) #4

Argh! I JUST found that after hours of searching. I don’t yet understand how to find information about something like, for example, _ThisRow_Before, without a ridiculous search process or shear luck. It should be searchable… still, thank you very much for the help.

(Keith Winston) #5

I am still failing at having a workflow only send the row that has changed in the process of triggering the action. I’ve got Condition =

[_THISROW_BEFORE].[ReportsSent] < [_THISROW_AFTER].[ReportsSent], but it sends me all the records. I can’t figure out how to limit it to the one record. Perhaps < doesn’t work, since _ThisRow_After might be weird for rows that didn’t change, and maybe that’s what is meant in the “Triggering Email” link above (that’s not very clear). But even with the Not(IsBlank stuff, it’s not working. That is, maybe one has to use <>, and can’t use <, with _Before & _After.

(Keith Winston) #6

However, to finish that thought, <> doesn’t work either.

(Keith Winston) #7

Just for kicks, I moved the expression into the template, but that doesn’t work: the ReportsSent is not the “key” column, and also it can’t find the _ThisRow_After column. I didn’t expect this to work, but there’s nothing like desperation to drive creative, sloppy thinking.

(Keith Winston) #8

Hours later, one little step forward: IF I have a workflow _ThisRow_Before/After rule, it gets “overruled” by my <<Start…>> statement in my template. I only figured this out by looking at the template of the ClickToSendEmail example. However, I have a lot going on in my template (child tables or whatever you call them) so they all break in the absence of my high-level Start. Any further help will be appreciated. The example template in ClickToSendEmail is too simple to be helpful in illustrating this issue.

(Aleksi Alkio) #9

The problem is this formula [_THISROW_BEFORE].[ReportsSent] < [_THISROW_AFTER].[ReportsSent]. When the ReportsSent is blank, the app will give you TRUE (because of blank against blank). You should change that formula like… AND(ISNOTBLANK([ReportsSent]),[_THISROW_BEFORE].[ReportsSent] < [_THISROW_AFTER].[ReportsSent]) and it should work.

(Keith Winston) #10

Thank you but no, Aleksi, that’s not the problem. I have used the formula, but I don’t need it: one of the two fields is guaranteed to be non-blank. In any case, that part isn’t where it’s breaking: the problem is that, apparently, if I try to send only one record to the template BUT the template has a Start statement that doesn’t have the Before/After clause (maybe I can just add that to the Start statement, hadn’t thought of that), then the Start overrides the Before/After Condition in the Workflow. I know this because as soon as I removed the Start, it started working. I got the idea to remove it because that’s how your ClickToSendEmail template is set up. So I’m left with the problem that I can trigger a template to be sent with only the current record, but only if it doesn’t have a Start statement, and if that’s true, it can’t have any Children Start statements/child tables/fields from related tables. Which breaks everything I’m trying to do.

(Aleksi Alkio) #11

Okay… one easy way is this… add a datetime column (ReportSent) and then create an action button with an epression NOW(). With the workflow condition AND(ISNOTBLANK([ReportsSent]),[_THISROW_BEFORE].[ReportsSent] < [_THISROW_AFTER].[ReportsSent]) you can then send the email.

When you add a new record, your initial value should be blank and it will keep the column’s value as blank. Next time when you open the record from the detail view and you press the action button, it will write the datetime value and the email is sent.

(Keith Winston) #12

Aleksi, I really appreciate your help, but you’re not yet on point. I’ve got that entire part working. I can get the email sent. I can get the before/after working. That’s not the problem: to do so, I’ve got to break my template. Here’s the issue: I need 1) a multi-level templated email sent that 2) only relates to the current record.

Before, my (highest-level) template Start statement sent a report involving the entire table. Now I want it only sending the “current” record (which is what the Before/After statement selects). However, it is a complicated template, with 3 levels of Start/End (this template works perfectly, when I use it on the entire table). When I use the before/after statement, the template START overrides the before/after (so the template still returns the entire table): Only by removing the Start entirely, just like the template you provide in your “ClickToSendEmail” example (which has no Start statement) does the before/after successfully select for the record I want. Great. Now I’ve got just the record I want reporting. The problem is that if I remove the top level Start (in a template with 3 levels of Start/End), the entire Template breaks. If I put the Start back in, the Before/After (single-record selector) breaks. I need both. Does that make sense? I realize it’s a very nit-picky problem.

It may be that I can change my Start statement, but I haven’t found an example of this and, in fact, can’t put my finger on general overview info on the Start statement. So I don’t know if I can put the Before/After selector in there: since I don’t understand EXACTLY where the front-end/back-end line is, or something, I can’t tell if the template START can do the Before/After test (since it would have to be able to get the before/after values, but those were associated with an Action, which changed a field, which triggered a Workflow, which used the Template: can that Template still see both Before & After values, to make the comparison?).

Ok, I’ve beaten this poor horse enough. Any attempts at help are still appreciated. Thank you.

(Philip Garrett) #13


I think you are getting really close.

If I understand you correctly, you should remove the top level Start expression and leave the two embedded Start expressions. This assumes that the outer Start expression in your Report is selecting records from exactly the same table that your Event triggered workflow is triggered by.

Here is the logic.

When you write a Report (aka Scheduled) workflow rule, your outer Start expression must select the set of records to be displayed.

For each record in the outer set of records, you can include an embedded Start expression to select the child records you wish to display for each of the outer parent record.

If you have a multi-level hierarchy consisting of parent, child, and grandchild records, you can repeat this pattern for each level in the hierarchy. So for each child record you can include an embedded Start expressions to select the grandchild records you wish to display for each child record.

An Event triggered workflow rule template is exactly the same as a Report template except for the outer Start expression. For a Report template, you must write a Start expression to select records from a single table. For an Event triggered workflow rule, you always start with a single record from a single table. If the Report workflow rule and the Event triggered workflow rule start with the same table, then the only differences in the templates is that: 1. The outer start expression is not needed in the Event triggered workflow rule.

  1. You are always starting with a single record in an Event triggered workflow rule , rather than a set of records in a Report workflow rule, so the outer part of your template is only formatting the data values from that single record.

The Start expressions and embedded templates for the child and grandchild records are the same for both the Report and Event triggered workflow rules.

(Keith Winston) #14

Hmm, we’ll, what I did to try to get it working was just remove the outer start expression, and the fields associated with the topmost record worked. All the child & grandchild fields broke, though, and I had the impression that it was because the embedded start statements had to work off that high-level statement. You make an interesting point, but it appears not to work exactly that way. I agree that I might be very close. Is there any doctoring of the child starts or something that might do it? I’ll look at it tomorrow some more. I also can’t really figure out if there are any debugging tools that help in this particular little part. Thanks for your thinking, I’m going to read through it more carefully tomorrow. I sort of have to get this working tomorrow morning.

(Keith Winston) #15

My old Start statement for the working Report process was

<<Start:SELECT(Properties[BlitzKey], true, true)>> (it selected the entire table)

OTOH my Condition statement for the Workflow is:

[_THISROW_BEFORE].[ReportsSent]<[_THISROW_AFTER].[ReportsSent] (it selects only the changed row, and only works if I disable the Start statement).

The target data for the Workflow is the Properties table.

Please note, I don’t need the And(isnotblank()) machinery, it doesn’t make a difference as noted in prior posts.

The child and grandchild statements in the template fail if I take out the Start statement, and the Condition statement is ignored (the “row selector”) if I leave the Start statement in.

That’s as concise as I can state this I think. I think I only need one of them, and it needs to be different. I can’t tell how, yet.

(Philip Garrett) #16


I am not sure I am following.

I am assuming you would use an event triggered workflow rule. In this model, the user is looking at a particular table record. They then do something that updates a field in that record. They could either explicitly change a field value, or they could click a button that invoked an action that changes a field value.

When that change is synced to the server, the event triggered workflow rule is invoked. It generates and sends the email. It can base that email on the data values in the updated record. One sample illustrates the case where the email recipient is specified in the updated record. Another, illustrates the case where the user selects specific PDF attachments to include with the email.

I got lost when reading the last two sentences in your message. I don’t think you need a slice to do this but I may be missing something.

(Philip Garrett) #17


This article shows how to do this - Triggering Email, SMS, or Notifications from the App

Triggering Email, SMS, or Notifications from the App

(Keith Winston) #18

Thanks Phillip. I was sort of building off of that. I want them to be able to send an email even when they have no update or change to the data, so I am creating this new column ReportsSent. I’m excluding other changes by only counting increments in that column.

Right now I’m stuck at the “send a email/workflow/report based only on the current row” part. I can’t figure out how to set up a slice that only looks at the current row.

(Philip Garrett) #19


That sounds perfect for an Event Triggered workflow rule.

When you click the button on the client, it can update the value of a field in the record.

When the user does the sync, that single updated record is sent to the server.

The server will save the update and notice that there is an Event Triggered workflow rule for that table that should be triggered on update.

You can write a condition on the rule to check for specific field values in the updated record. This allows you to trigger the rule in some cases and not others.

The workflow rule will be invoked and your workflow rule logic can directly reference the fields from that single updated record. It can simply uses the names of the fields because it know exactly which record is being updated.

You can create the PDF attachment and send the email to the appropriate person.

(Philip Garrett) #20


If this is not clear send me an email at