Jump to content

How to display Generated PDF link conditionally

Recommended Posts

Hi. I have a datapage that will allow users to create a PDF treatment sheet for patients enrolled on cancer studies. There are multiple studies and each treatment sheets looks quite different, so I have created unique treatment sheets in Caspio's document templates.



The datapage that is a tabular report that filters data based on my pre-defined criteria. I allow inline insert at the top as a means for users to add records. All records in the results are ALWAYS associate with one study. 

When the user completes the fields in the inline insert, a record is generated. I would like the results in this record to show the Generated PDF link for the appropriate study.

I cannot figure out how to do this. Since the generated pdf link doesn't show up as a field, I cannot use a calculated field to show the PDF that I want.

So I tried creating all of the links to the PDFs...



Below I passed a study parameter [@studyid] so the only records displayed are for the one particular study. But all tx sheets column's are there I cannot figure out how to hide the columns conditionally.



What I would like to do is pass a parameter [@studyid] and have that study's tx sheet be the only thing displayed. One treatments sheet template for each record.

Any guidance would be truly appreciated. 




Link to comment
Share on other sites

Hello @kcastagnaro

Assuming there are 5 studies and there is a correlation between studyid and generate PDF column, you can do the following:

1. Hide all PDF column by default using CSS:



tr > th:nth-child(5), tr > td:nth-child(5) {
display: none;
tr > th:nth-child(6), tr > td:nth-child(6) {
display: none;
tr > th:nth-child(7), tr > td:nth-child(7) {
display: none;
tr > th:nth-child(8), tr > td:nth-child(8) {
display: none;
tr > th:nth-child(9), tr > td:nth-child(9) {
display: none;


Where numbers 5-9 represent the order position of PDF columns in a tabular report

2. With JavaScript, show only 1 column that corresponds to the value of passed studyid parameter:

if (typeof DataPageReadyHandler == 'undefined') {

const studyColumnDependencies = [{
columnPosition: 5, // position of PDF column for study with UZ5U2HTP ID
studyID:  'UZ5U2HTP' 
}, {
columnPosition: 6, // position of PDF column for study with 84DMNK2T ID
studyID:  '84DMNK2T'
}, {
columnPosition: 7, // position of PDF column for study with MVDIF4JM ID
studyID:  'MVDIF4JM'
}, {
columnPosition: 8, // position of PDF column for study with 7PA40M6B ID
studyID:  '7PA40M6B'
}, {
columnPosition: 9, // position of PDF column for study with A361MWHP ID
studyID:  'A361MWHP'

const getPositionOfCurrentStudyColumn = () => {
let studyID = '[@studyid]'
if(studyID=='') {return -1}
let position = -1
for (let i=0;i<studyColumnDependencies.length; i++) {
if (studyColumnDependencies[i].studyID == studyID) {
position = studyColumnDependencies[i].columnPosition
return position

const DataPageReadyHandler = () => {
let currentStudyColumn = getPositionOfCurrentStudyColumn()
if (currentStudyColumn == -1) {return}
document.querySelectorAll(`tr th:nth-child(${currentStudyColumn}), tr td:nth-child(${currentStudyColumn})`).forEach(cell=>{
cell.style = 'display: table-cell;'
document.addEventListener('DataPageReady', DataPageReadyHandler)

Customize the studyColumnDependencies array to map studyIDs with corresponding PDF column positions.

Here is a DP example: 


You can change the value of studyid parameter to the one of mentioned in studyColumnDependencies array above to see that different generate PDF columns will be displayed based on the studyid

Link to comment
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.

Reply to this topic...

×   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.

  • Create New...