Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Obtaining Return Value from a script object

Avatar

Former Community Member
I have a function where I am calculating a value which needs to be passed back. For example, say the function Calc gets parameters m and n via Calc(m,n) and the function calculates p = m*n. Calc(m,n,p) doesn't work. Placing a Return p at the doesn't work either and I am out of options at that point.



How do I return the value of p back. There seems to be some sort of a XFAobject issue here that I don't understand. Any help would be appreciated.
2 Replies

Avatar

Level 2
In Designer 8.2.1, Added 2 text boxes to a form design. box1, box2.

Inserted a Script Object Scripts4 by right clicking root level form1.

Added a function in Scripts4 -

function calcu(m, n)

{

//xfa.host.messageBox("values .." + m);



var p = m*n;

return p;

}



-----



In box1.exit event; wrote following script:



v= Scripts4.calcu(box1.rawValue, 10);

box2.rawValue = v;



-----



Preview PDF, entered 14 in Box1. Clicked on Box2. It shows 140.

Working as expected.

Avatar

Former Community Member
statke,



Thank you so much! That was VERY helpful!



If you don't mind I have one more question that maybe you can help with.



I want to pass two Tables to a function and work on them in the function. When I reference any row from the passed table it doesn't understand it like it does the vars m and n in the example you showed me. Is there a different way to reference tables (passed as paramters) in a function?



Again, thanks a lot for your help!