Solved

JavaScript bot error

  • 11 December 2023
  • 1 reply
  • 81 views

Badge +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?

icon

Best answer by LoganPrice 11 December 2023, 17:03

View original

1 reply

Userlevel 3
Badge +9

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.

Reply