Jump to content
  • 0

Have calculated field in tabular report


Question

Hi,

 

I have a calculated field in a tabular report results with the following value.

(SELECT COUNT(nurse_id) FROM users WHERE nurse_id=[@field:Nurse_ID])

Then I have an HTML link based on that calculated field, as follows

<a href="" id="myLink"></a> <script>
if([@calcfield:1#] != 0)
{
document.getElementById("myLink").innerHTML = "Edit Password";
document.getElementById("myLink").href = "https://MyAcct.caspio.com/dp/1234?Nurse_ID=&Nurse_ID";
document.getElementById("myLink").target = "_blank";
}
else
{
document.getElementById("myLink").innerHTML = "Add Password";
document.getElementById("myLink").href = "https://MyAcct.caspio.com/dp/1234?Nurse_ID=&Nurse_ID";
document.getElementById("myLink").target = "_blank";
}
</script>

This works as expected but only for first row.

How can I have this feature working for each row in the report?

 

Thanks

Link to post
Share on other sites

5 answers to this question

Recommended Posts

  • 1

Thanks, the following code should work:

<a href="#" id="myLink_[@field:Nurse_ID]" target="_blank"></a>
<script>
if([@calcfield:1#] > 0){
  document.getElementById("myLink_[@field:Nurse_ID]").innerHTML = "Edit Password";
  document.getElementById("myLink_[@field:Nurse_ID]").href = "https://MyAcct.caspio.com/dp/1234?Nurse_ID=[@field:Nurse_ID]";
}else{
  document.getElementById("myLink_[@field:Nurse_ID]").innerHTML = "Add Password";
  document.getElementById("myLink_[@field:Nurse_ID]").href = "https://MyAcct.caspio.com/dp/1234?Nurse_ID=[@field:Nurse_ID]";
}
</script>

I was not able to test this code but please let me know if it works as expected.

Link to post
Share on other sites
  • 0
3 minutes ago, douvega said:

Hi @BFuchs

Your code is not working for all rows since you are generating several items with the same id "myLink", remember each id must be unique.

Could you please identify a field within the table which is unique so I can provide you with the proper JS? Tell me the full name of the unique field.

Hi douvega,

Field Nurse_ID should be unique.

Thanks,

Ben

Link to post
Share on other sites
  • 0
6 minutes ago, douvega said:

Thanks, the following code should work:


<a href="#" id="myLink_[@field:Nurse_ID]" target="_blank"></a>
<script>
if([@calcfield:1#] > 0){
  document.getElementById("myLink_[@field:Nurse_ID]").innerHTML = "Edit Password";
  document.getElementById("myLink_[@field:Nurse_ID]").href = "https://c2esh547.caspio.com/dp/0ab94000a09b2aef99b84547b2b8?Nurse_ID=[@field:Nurse_ID]";
}else{
  document.getElementById("myLink_[@field:Nurse_ID]").innerHTML = "Add Password";
  document.getElementById("myLink_[@field:Nurse_ID]").href = "https://c2esh547.caspio.com/dp/0ab9400088235fb518164a2b828e?Nurse_ID=[@field:Nurse_ID]";
}
</script>

I was not able to test this code but please let me know if it works as expected.

Looks like the HTML portion is working now, but perhaps something is wrong with the calculated field as well.

See attached.

Thanks,

Ben

Capture.PNG

Link to post
Share on other sites
  • 0
23 hours ago, BFuchs said:

Hi,

 

I have a calculated field in a tabular report results with the following value.


(SELECT COUNT(nurse_id) FROM users WHERE nurse_id=[@field:Nurse_ID])

Then I have an HTML link based on that calculated field, as follows


<a href="" id="myLink"></a> <script>
if([@calcfield:1#] != 0)
{
document.getElementById("myLink").innerHTML = "Edit Password";
document.getElementById("myLink").href = "https://MyAcct.caspio.com/dp/1234?Nurse_ID=&Nurse_ID";
document.getElementById("myLink").target = "_blank";
}
else
{
document.getElementById("myLink").innerHTML = "Add Password";
document.getElementById("myLink").href = "https://MyAcct.caspio.com/dp/3456?Nurse_ID=&Nurse_ID";
document.getElementById("myLink").target = "_blank";
}
</script>

This works as expected but only for first row.

How can I have this feature working for each row in the report?

 

Thanks

Actually I just had to add Target.Nurse_ID and it works.

Thank you douvega!!

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...