Send HTML formatted mail from Pentaho - html

I need to loop through a database table and send a html formatted mail.
Nothing complex, a text value followed by a hyperlink.
I tried with xml and xsl transformation but couldn't get desired results.
ALso, advise on whether its better to construct hyperlink in PostGressql or is it okay from Pentaho
I tried with a Table Input and a Javascript step. Thing is it outputs for each row. i need to combine and concatenate each row output to form result HTML

With Pentaho: get your data with a table input, make the html (for example with a java script), get the mail parameters (addresse, attachement, etc,...) from a grid or a constant step, and give the whole to the mail step.
With the javascript you built a -tag by row named html, but you need only one message. So you group them with a Group by step (no Group field, subject=html, type=Concatenate strings separated by, value=empty). You can then drop it in the Mail step.
But the Mail step needs some more information (recipient, sender, subject, server, port,...). You can put them in the flow with a Constant step.
In view of your use-case, it may surprise you that you have to put this data in the flow rather than to feed a box in the Mail step. This is because this step is designed to send a mail personalized for each recipient.
And now that you know how to do it, refrain from sending 100000 mails to every one you can.

Related

Query Google Admin User directory comparing parameters

I'm trying to filter my users list by comparing two parameters
query="EmployeeData.EmployeeID=externalId"
EmployeeData.EmployeeID is a custom schema that is populated, with a cron job, with the same value as externalId.
Of course I let the cron do the field copy only if necessary, this is the reason I'm trying to filtering the users list.
In the way i wrote seems that the query trying to looking for a value "externalId" into the EmployeeData.EmployeeID ignoring that "externalId" is a even a field
any suggestion?
The way your code is written, the query sent to Google's servers is as you correctly guessed the following:
EmployeeData.EmployeeID=externalId where your actual externalId is not sent but rather the string "externalId".
To replace this string for the actual value of your variable, you can use what is called "string concatenation" 1. To do it, you just need to modify your code as shown below:
query="EmployeeData.EmployeeID=" + externalId;
This way, the query will be sent as you need to Google's servers.

Getting the value of a particular cell with AJAX

My goal is very simple and I would guess it is a very common goal among web developers.
I am creating a Rails (5.1) application, and I simply want to use AJAX to get the value of a specific cell in a specific row of a specific table in my database (later I am going to use that value to highlight some text on the current page in the user's browser).
I have not been able to find any documentation online explaining how to do this. As I said, it seems like a basic task to ask of jquery and ajax, so I'm confused as to why I'm having so much trouble figuring it out.
For concreteness, say I have a table called 'animals', and I want to get the value of the column 'species' for the animal with 'id' = 99.
How can I construct an AJAX call to query the database for the value of 'species' for the 'animal' with 'id' = 99 .
Though some DBs provide a REST API, what we commonly do is define a route in the app to pull and return data from the DB.
So:
Add a route
Add a controller/action for that route
In that action, fetch the data from the DB and render it in your preferred format
On the client-side, make the AJAX call to that controller/action and do something with the response.

Removing Headers in eText in BI Publisher

We have a scenario where we should not display the header in the output in CSV using eText template.
Our output looks like this:
Header000001 Header000002
------------ ------------
Adetail1 Bdetail1
Adetail2 Bdetail2
Adetail3 Bdetail3
Desired output is:
Adetail1 Bdetail1
Adetail2 Bdetail2
Adetail3 Bdetail3
We tried all possible options in eText template like removing header section, verifying the data using BI Publisher Desktop tool, verifying logs etc.
We are not getting any error in BI Publisher Desktop tool.
Same question has been posted by somebody some time ago and it was resolved, but solution was not provided.
It would be very helpful if anybody can provide the exact solution.
The header will just be another block in your eText template. You can use the <DISPLAY CONDITION> command to skip printing that block in the output. The display condition command specifies when the enclosed record or data field group should be displayed. The command parameter is a boolean expression. When it evaluates to true, the record or data field group is displayed. Otherwise the record or data field group is skipped. You can just give condition as false, and that block will be skipped.
I have created a template using the provided data xml to output a CSV, without headers. A delimiter based template is used, but the header is not printed.
Access it from here.

Send Mail Task based on output from Execute SQL Task

How to send an email based on the ouput from the execute SQL Task in SSIS? If the query returns any results I would like to send an email if not the email should not be sent.
Do you want to send the results of the query in the mail or not?
Either way, you can do this:
Capture the number of rows returned by your query in a variable
Use an expression in your precedence constraint to send the email only if the rowcount was greater than zero
If you want the results of the query in the email, then the simplest thing is probably to write them to a flat file and then send the file as an attachment.
Alternatively, do the whole thing in a stored procedure using sp_send_dbmail and just call the procedure from your package.
It's probably a bit clunky, but you could send the results of your Execute SQL task to a variable, then use a For Loop container based on that variable. Put the Send Mail task within that For Loop container. The challange in that is only running the Send Mail once, no matter if the count is 1 or more. If your count was saved as a bool, perhaps that would work?
You could put another step in between, put in a Script Task that takes the count and returns a 0 or 1, and then use the For Loop with the Send Mail task within.
Like I said, clunky.

Send email to dynamic recipient SSIS Send Mail Task

I have an SSIS package which is going to be deployed on test, staging, and finally production.
It has a couple of "Send Mail Tasks",say 10.
As developer, I put my email address as the recipient of the email.
Currently, for the test person, I need to change all the "To"s in all the script task to e.g. "TestPerson#test.com". If following the paradigm of hard-coding the emails this way,I need to change the recipient email 30 times!!! (10 for each stage stated above)
Just wondering if there is any way to inject To field(recipient) dynamically. e.g. from a variable. like I have done for the "MessageSource"
You can set the ToLine of the Send Mail task to be the value of a variable, using an Expression from the Properties window of the task.
We use a SQL table containing a list of email recipients for various conditions (table columns of kemail, emailaddress, success, error) and set flags in the table to 0=no, 1=yes for that particular user to receive emails on particular conditions.
Then create a variable that contains a delimited list of your recipients then use an expression to set "ToLine" for the send mail task.
The only thing to watch here is that you don't end up with a no records returned from the SQL table. We always have our "support" email address always having all the bits set, to avoid this.
So the package wont need to be modified when a new user needs to receive email updates.