Skip to main content
Announcements
Defect acknowledgement with Nprinting Engine May 2022 SR2, please READ HERE
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

NPrinting - Use different email messages based on variable

Hi Everyone,

I've been asked to create an NPrinting task (ver. Nov 2017) that ships a report to a bunch of users. The tricky part is that I have to use a different email message based on a variable value from Qlik Sense (ver. Nov 2017). I figured "Hey! I can use the embedded reports feature!", but I've had some issues.

Where I'm at: I've created an HTML report with my message, then added the HTML report to my task and embedded it into the email message - works great. The text from the HTML report is in my email. But I've hit a roadblock when trying to conditionally decide which message should be included.

What I've tried:

  • Create a single HTML report and use a formula to determine which message to show. The problem is that an if statement requires me to wrap the tags and message text (yes, I need to include the tags as the messages have completely different markup) in single quotes, which the HTML page just displays as literal text (including the quotes!). This is my ideal solution - one "Message" report - which conditionally determines which text to display
  • Create a message report for each different message. Add them all to the task. Create a condition that connects to the Qlik Sense variable. Add the condition to each message report and give each the appropriate condition value so that only one is generated. Embed all of the reports into the message. This didn't work - the task doesn't error out, it just hangs and never finishes. I'm assuming that NPrinting is looking for the reports to embed but never finds them because they aren't generated.

I'm not quite sure how to accomplish this, other than creating a separate task for each message, running all the tasks and using conditions on the actual reports so that only one of the tasks actually sends something. Really don't want to go down that road (what if I have 10 different messages??)

Thanks!!

3 Replies
ogster1974
Partner - Master II
Partner - Master II

I cant wait to get my hands on the embedded functionality.  Need to get my upgrade done.

On the only message front could you add your message into the Qlik Sense App with a flag to id message 1, 2 3 etc... and then use the user filter to filter down to the mesage you want to display that way you will just have one message field in your report.  My guess is they have some role that determines their communication method.

Anonymous
Not applicable
Author

Hey Andy, thanks for the help - this made me think to try creating a Qlik Sense variable for each message, then use a separate variable to handle the conditional message selection. I then tried to drop this variable into the NPrinting report as a variable/formula (tried both). Unfortunately the problem is still that I need to include the HTML markup into the message, and NPrinting sees the markup as text rather than HTML tags. There could be something I'm missing here.

I then tried to use javascript within the HTML report. I got this to work:

The javascript:

       <script type="text/javascript">

    

       function showMessage()

       {

       document.getElementById("Full").style.display = "none";

       document.getElementById("Meets").style.display = "none";

       document.getElementById("Below").style.display = "none";         

    

       document.getElementById("%%MessageType%%").style.display = "inline";

       };

      

       </script>

The HTML report body:

<body onload="showMessage()">

<div>

<p> Your current status known compliance is %%ComplianceRate%% </p>

<div id="Full">

       <p>You're awesome - fully compliant!</p> 

</div>

<div id="Meets">

       <p>You're doing great!</p>

</div>

<div id="Below">

       <p>You're getting there</p> 

</div>

</div>

</body>

The MessageType formula expression using my Qlik Sense variable:

if($(vPercentInfluenzaStatusKnown) = 1, 'Full',

if($(vPercentInfluenzaStatusKnown) >= 0.8, 'Meets',

'Below'))

The above works for a HTML report when viewed in the browser, but the javascript doesn't execute when embedded into an email .I realized later that this is probably because it's a potential security risk (I know next to nothing about javascript). Sigh.

I'm giving up on this for now. If I figure it out I'll post in this thread.

Lech_Miszkiewicz
Partner Ambassador/MVP
Partner Ambassador/MVP

<SCRIPT > I have been there, I have done that..

I tried also use script in my html to build google charts and hit the same roadblock and I gave up realisisng that mail client will not support it - SHAME

------------------------------------------------

Back to your question:

If you want to go this path you will have to handle all in Qlik Sense / QlikView side. So depending on variable you need to produce outcome.

Things you need to consider are:

  • condition needs to be evaluated within the same object as you will only reference always the same object in NPrinting. Therefore you will end up with nested if statements or set analysis. If yo uhave created 3 messages in 3 different objects yo uneed to put all of them into one object and use condition in Qlik to decide which part of message is getting sent

example:

Let vVar1 = 'Today is Monday the first day';

Let vVar2 = 'Today is Tuesday the second day';

Let vVar3 = 'Today is Wednesday the third day';

above you have 3 variables. What you currently are doing is looking at them as a separate objects and want to apply condiotion which of them you want to show in NPrinting- right?

My idea is that you only need to have one variable like:

Let vSingleVariable = If(condition1 = true(), vVar1,If(condition2 = true(), vVar2,If(condition3 = true(), vVar3.... etc...)))

then in NPrinting you only use vSingleVariable to show your message, and its content gets calculated in Qlik.

Obviously i have presented example with variables, maybe you have charts, textboxes or whatever - still, the principle is the same.

Can you share a mockup what is your variable, how is it calculated? Is it recipient based? and what is your report scenarios likely looking like (template).I am sure we will find a solution for your request as it seems to be achievable.

regards

Lech

cheers Lech, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful to the problem.