• 0
Clint

SQL with an HTML Output

Question

I have a working conditional statement using SQL. However, the output (following the "then" statement outputs plain text.

Does anyone know how to force it to be formatted as a clickable link?

Here's the full statement: 

CASE

WHEN [@field:connect_PIF_ER_eval_complete]='' then '<a href="participant_evaluation.html?ER_ID=[@field:ER_Events_1_ER_ID]&Ev_Type=[@field:ER_Events_1_Event_Type]">Evaluation</a>'

ELSE 'Evaluation Completed'

END

I'm sure it's obvious, I'm just not sure what needs to surround the href tag. 

Thanks!

Share this post


Link to post
Share on other sites

4 answers to this question

  • 0
On 4/19/2017 at 1:39 PM, Clint said:

I have a working conditional statement using SQL. However, the output (following the "then" statement outputs plain text.

Does anyone know how to force it to be formatted as a clickable link?

Here's the full statement: 


CASE

WHEN [@field:connect_PIF_ER_eval_complete]='' then '<a href="participant_evaluation.html?ER_ID=[@field:ER_Events_1_ER_ID]&Ev_Type=[@field:ER_Events_1_Event_Type]">Evaluation</a>'

ELSE 'Evaluation Completed'

END

I'm sure it's obvious, I'm just not sure what needs to surround the href tag. 

Thanks!

You can't use html tags in calculated fields.  You need to use Java Script. As far as I understand, you need to show link only if the field is blank.

I would recommend using the following script in html block

<script>
if ('[@field:connect_PIF_ER_eval_complete]'.length<1) {
document.write('<a href="participant_evaluation.html?ER_ID=[@field:ER_Events_1_ER_ID]&Ev_Type=[@field:ER_Events_1_Event_Type]">Evaluation</a>');
}
else {
document.write('Evaluation Completed');
}

</script>


 

Share this post


Link to post
Share on other sites
  • 0
On 4/21/2017 at 5:35 AM, Mathilda said:

You can't use html tags in calculated fields.  You need to use Java Script. As far as I understand, you need to show link only if the field is blank.

I would recommend using the following script in html block


<script>
if ('[@field:connect_PIF_ER_eval_complete]'.length<1) {
document.write('<a href="participant_evaluation.html?ER_ID=[@field:ER_Events_1_ER_ID]&Ev_Type=[@field:ER_Events_1_Event_Type]">Evaluation</a>');
}
else {
document.write('Evaluation Completed');
}

</script>


 

Hi Mathilda,

Thank you for the script. It worked for me as well. However, the script is only showing on the first page of results and when I click to the next page of results, it doesn't show. Do you know why?

 

Screenshot (135).png

Screenshot (136).png

Share this post


Link to post
Share on other sites
  • 0
11 hours ago, DaeBo said:

Hi Mathilda,

Thank you for the script. It worked for me as well. However, the script is only showing on the first page of results and when I click to the next page of results, it doesn't show. Do you know why?

 

Screenshot (135).png

Screenshot (136).png

Hi, I'm glad that it works for you as well :)

Try disabling AJAX on your report, it should helps. You can do that on 'result page options' screen

Hope that helps

Share this post


Link to post
Share on other sites
  • 0
16 hours ago, Mathilda said:

Hi, I'm glad that it works for you as well :)

Try disabling AJAX on your report, it should helps. You can do that on 'result page options' screen

Hope that helps

Thanks, that worked!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now