Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Run JavaScript passed in via form data.

Avatar

Level 2

Ok I am in SAP.

SAP populates some hidden fields. 

so now the field, well say fieldX has the rawValue = sectionX.fieldY.presence = "open"'

xfa.host.messageBox("test " + fieldX.rawValue);

********popup says************************************

test sectionX.fieldY.presence = "open";

***********************************************************

Now I want to take this code in fieldX and actually make it run. 

I was doing this in a scriptObject section I created.  The function I created sees the value of fieldX, but I don't know how to make it run the code stored in fieldX.

thoughts?

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

You should be able to use the JavaScript eval function, https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval.

So;

eval(fieldX.rawValue)

This value of this in a script object will be the top most form object.   If you run it in a form object like a button this will be the button.

Good luck

Bruce

View solution in original post

1 Reply

Avatar

Correct answer by
Level 10

Hi,

You should be able to use the JavaScript eval function, https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval.

So;

eval(fieldX.rawValue)

This value of this in a script object will be the top most form object.   If you run it in a form object like a button this will be the button.

Good luck

Bruce