155
Views
5
Comments
Call JavaScript function
Application Type
Reactive

Hello,

I have a JS function, e.g.

function GetId() {

Id = ...

return Id; }


How can I call this JS function and show the Id in the screen?

I have tried putting it in the module Scripts and also tried directly putting it into a JS element in a screen action, but I am struggling a bit. Thank you!

 


Hi @Cute Bear, I am adding an OML with a working example. I have provided examples for both screen JS node and global JS.

Also do read the documentation suggested by @Ricardo Pereira.


Thanks
Gitansh Anand

Test.oml

Hello,

@Cute Bear 

You can easily call this JS function and show the Id in the screen.

in js widget you have to create one output variable and call the function GetId() and assign to that output variable

 e.g. 

function GetId() {

Id = 7

return Id; 

}

$parameters.Id = GetId();

Use Id output variable in your screen

I have attached sample oml check that.

Thanks Regards,

Rizwan

SampleTest.oml

05/11/2023 
hi..I don't know if your answer worked for Cute Bear, but it worked perfectly for me.. Thanks for sharing :)

Sorry my English :|



Hi @Cute Bear 

You can do it like this, in your module interface tab create a new script 


Then write code like this -


and call the functions like this - 

 

I hope it'll help you to solve your issue,

Thanks

Deep

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.