Custom Script: Return value to bot task using executeJavascript

Hi, I have to extract some values from the webpage. But I couldn’t succeed with Actions. So I came up with a solution to extract using javascript. So for that, I used executeJavaScript in a custom action. But I don’t know how to return the value from it. Can you please help me with this?

Or suggest me another way to extract it. Thanks.

Hi @Atul can you share your script?

Thank you

@Atul could share your script to have a look? Thank you.

Hi @Atul,

Thank you for posting.

Please take a look at the sample script of how to return value from executeJavaScript(scriptCode) in Kb site and the link is shared below,

https://kb.workfusion.com/display/RPA/Script+Class

find this line “executeJavaScript(scriptCode)” in that page which will give enough information.

Hope this helps and have a great day :slight_smile:

Hi, I found the solution for the above. But now I am facing another challenge. Please find below a script.
“executeJavaScript(document.getElementById(‘id’).value=Variable”)

Now my challenge is to pass recorder variable in custom action, which can replace “Variable” in above. Please let me know, if you can help me on this. Thanks.

Hi, Thanks for your response, I forgot to update but I found the solution for the above query. If you can help on new query that I have in the reply section to ashapkina. It would be big help for me. Thanks

Hi @Atul,

Thanks for your response :slight_smile:

Please go to the same link where there is a sample code of how to pass arguments inside executeJavaScript(String code, Object… args),

https://kb.workfusion.com/display/RPA/Script+Class

Please check it in the link to have detailed information.

Hope this helps :slight_smile:

1 Like

Hi @aravindhan_mr, I checked the “https://kb.workfusion.com/display/RPA/Script+Class”. But I believe it can be used only to get value in a variable, not to set the value from a variable.

If it’s not that way, can you please give me one sample where it sets the value using a variable.
TIA!

Hi @Atul,

Please find the sample script which will give you some idea about arguments passing,

script.txt (570 Bytes)

Thank you for response and Have a great day :slight_smile:

2 Likes

Thank you so much @aravindhan_mr.

2 Likes