Hi @sp4448,
You cannot use document.write in a dynamic hyperlink, but you can hide a blank field using an if-then-else macro. This feature is explained here:
https://wpdataaccess.com/docs/data-explorer/dynamic-hyperlinks/
Please scroll down to the if-then-else macro section. The nested macro examples shows how you can catch a blank field value.
Let me know if you need further assistance.
Good luck,
Peter
Thread Starter
sp4448
(@sp4448)
I’m not familiar with macros and google isn’t being helpful.
With the nested macro example, what does each line mean?
This is what I’m guessing…
If product image is ____ (blank? not blank?)
and if product name equals sneakers
show this image
If product name does not equal sneakers
show N.A.
end macro
If product image is ____ (blank?)
show javascript link
end macro
Hi @sp4448,
You initial if statement:
if (""!="$$FILENAME$$") {
...
}
Written as macro:
#macro if "$$FILENAME$$" != ""
...
#macro end if
Replace the … with your own HTML. It is simpler than javascript and above all much safer.
Hope this helps,
Peter
Thread Starter
sp4448
(@sp4448)
Thank you Peter! You’ve been incredibly helpful and patient.
I was able to make it work with blank fields. It hid the field when blank, and didn’t hide it when not blank.
On its own it works perfectly.
However I was trying to include it as part of a paragraph and it won’t work then.
This works:
#macro if "$$FILENAME$$" != ""
<img src=$$FILENAME$$>
#macro end if
This doesn’t work:
Other $$FIELD$$
#macro if "$$FILENAME$$" != ""
<img src=$$FILENAME$$>
#macro end if
More $$FIELDS$$
Is the latter possible?
Hi @sp4448,
You can use other columns in a macro, but they have to be within the same table. You cannot access columns from another table.
If you need to access a column from another table in a publication, you can write a view that contain the other column. The Data Publisher works with views just like tables. This is possible with projects as well, but eliminates the possibility to support transactions.
Does this help?
Thanks,
Peter
Thread Starter
sp4448
(@sp4448)
They’re all in the same table
Hi @sp4448,
Please check your column name in the Data Explorer:
– Open the Data Explorer
– Find your table
– Click Manage
– Press tab Columns
Make sure your write the column name exactly as shown on the Columns tab. Depending on your installation column names can be case sensitive.
Hope this helps,
Peter
Thread Starter
sp4448
(@sp4448)
All column names are uppercase and match exactly. They appear without a macro but won’t appear if using a macro.
Can you share your full dynamic hyperlink code? You can use the contact form on the plugin website if you prefer to share this information in private.
Thanks,
Peter