Skip to main content
Solved

JavaScript bot error

  • December 11, 2023
  • 2 replies
  • 465 views

Forum|alt.badge.img+1

I have a JS that works, I can run it from my Shell or CMD, but when I try to execute it in AA i am getting bot error. After removing all the possibilities I found out there is an issue with additional libraries. In my script I have const fs = require('fs') so this is the first problem and next is require('html-pdf') because all my script is doing just taking an html file from the folder and saving is as pdf. 

As I said the script works, I have all the libraries but it doesn’t work from the AA level. Any advices?

Best answer by LoganPrice

I don’t think AA allows the use of importing libraries with “require”. See this answer here:

I want to call the stored procedure using JavaScript in AA | Community (automationanywhere.com):
 


 

For the fs commands, you might consider using AA built in File action to replace the JavaScript functionality (I know, that sucks). For the HTML to PDF, I dont know of built in AA actions, but there might be a one-shot solution in the bot store, or you might be able to just use AA actions to 1)open html in browser 2)print page from browser

 

Here is what I would do, skipping the JS altogether:

 

The code essentially:

  • opens your html file (I’ve tested and this works)
  • uses keystrokes to simulate printing the page to pdf

 

I think this would be your simplest bet from what I can see.

View original
Did this topic help answer your question?

2 replies

LoganPrice
Most Valuable Pathfinder
Forum|alt.badge.img+12
  • Most Valuable Pathfinder
  • 77 replies
  • Answer
  • December 11, 2023

I don’t think AA allows the use of importing libraries with “require”. See this answer here:

I want to call the stored procedure using JavaScript in AA | Community (automationanywhere.com):
 


 

For the fs commands, you might consider using AA built in File action to replace the JavaScript functionality (I know, that sucks). For the HTML to PDF, I dont know of built in AA actions, but there might be a one-shot solution in the bot store, or you might be able to just use AA actions to 1)open html in browser 2)print page from browser

 

Here is what I would do, skipping the JS altogether:

 

The code essentially:

  • opens your html file (I’ve tested and this works)
  • uses keystrokes to simulate printing the page to pdf

 

I think this would be your simplest bet from what I can see.


LoganPrice
Most Valuable Pathfinder
Forum|alt.badge.img+12
  • Most Valuable Pathfinder
  • 77 replies
  • April 16, 2024

Hi @danuta.bahadir,

 

For the purpose of rounding out this Community’s knowledge base, would you mind sharing how you ended up creating a solution for your problem? Your answer may help someone in the future!

 

Thanks,

Logan


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings