Fusion Manage Forum
Welcome to Autodesk’s Fusion Manage (formerly Fusion 360 Manage) Forum. Share your knowledge, ask questions, and explore popular Fusion Manage topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Javascript advanced printviews

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
Anonymous
802 Views, 4 Replies

Javascript advanced printviews

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

4 REPLIES 4
Message 2 of 5
jpiggee
in reply to: Anonymous

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>

Joseph Piggee
Fusion 360 Administrator
TPI Composites
jpiggee@tpicomposites.com
Message 3 of 5
Anonymous
in reply to: jpiggee

Thanks Joe for the quick response.

Message 4 of 5
Anonymous
in reply to: Anonymous

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

 

Message 5 of 5
jpiggee
in reply to: Anonymous

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.

Joseph Piggee
Fusion 360 Administrator
TPI Composites
jpiggee@tpicomposites.com

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report