Hi,
Does anyone know if I can embed javascript in the advanced printviews and if so will it run when loading the view?
I need to cut a string and I can't use postgre sql in a computed field as the source field is a picklist. I'm now hoping I can use the substring( ) method on my printview(I won't be using it on a creation script as it won't help with my legacy data).
Has anyone used JS in their advanced printview?
Thanks
Saoirse
Solved! Go to Solution.
Solved by jpiggee. Go to Solution.
Hi Saorise,
Yes, you can use client side and server side Javascript, this includes prompts and input request.
However, you can only accomplish this using the html editor for the completion of the task.
Below is an example of what can be done with this,
***Note***
All html elements must be included and written to the html soured editor, any other method may produce undesirable results.
<html>
<head>
</head>
<body>
<script>
var r=confirm("Press a button");
if (r==true)
{
x="You pressed OK!";
document.write("You pressed OK!")
}
else
{
x="You pressed Cancel!";
document.write("You pressed Cancel!")
}
</script>
<div class="section">
<table>
<tbody>
<tr><th class="header" colspan="2">${workspace.metadata.itemDetails.sections["cascade test"].name.value}</th></tr>
<tr><th>${workspace.metadata.itemDetails.sections["cascade test"].fields.GEAR.title}</th>
<td>
<script>
var testa = ${item.itemDetails.sections["cascade test"].fields.GEAR.value};
var testb= testa+40;
document.write(testb);
</script>
</td>
</tr>
<tr><th>${workspace.metadata.itemDetails.sections["cascade test"].fields.RATIO.title}</th>
<td>${item.itemDetails.sections["cascade test"].fields.RATIO.value}</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
Hi Joe,
My JS didn't work so I tested it outside of the HTML and I don't believe I can do what I want to do on a field that is a data type field 'picklist'.
Please see attached 2no. printviews. (1)The ERROR I get when trying to use a substring method on a picklist field and (2)How it runs fine if I substitute the field for one that is a single line text.
So given that the field is a picklist it won't read it as a string. Do you know of a way that I can easily convert this to a string?
Thanks
Saoirse
Saoirse,
You could try convert to string String() .
However, please understand you are a trailblazer in this, something’s may or may not work, I have not had the opportunity to test all possible JS commands.