Expand my Community achievements bar.

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

Obtaining name of object triggering event

Avatar

Level 2

If I've got a change event for a checkbox declared like this:

topmostSubform.Page2.Competitions_CB.Checkbox::change - (JavaScript, client)

how can I get this object path into a variable so I can process it and extract the "Competitions_CB" part? Even traversing up the object tree would be fine, but I can't seem to find which property returns object names.

I've been through all of the properties that sounded likely, in both xfa.event, event and this, but nothing seems to be what I'm after.

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

Using "this.somExpression" will return a string of the full object path;

xfa[0].form[0].topmostSubform[0].Page2[0].Competitions_CB[0].Checkbox[0]

You can also use "xfa.context.somExpression" to return the same thing, using xfa.context is handy when the code is in a script object and called from many object events.

Also, "parent.name" would return the "Competitions_CB" part, so parent.somExpression would return

xfa[0].form[0].topmostSubform[0].Page2[0].Competitions_CB[0]

Regards

Bruce

View solution in original post

3 Replies

Avatar

Level 2

I'm beginning to think this is not possible. Another hour of searching found nothing.

I popped a breakpoint in the change handler to inspect both global and local objects, but the debugger is too barebones.

I had a look at Assuredynamics' "Referencing Objects" example, and although it's not the point of the example and maybe would have confused the point of the example, I noted the light switch handlers each hardcode the specific light switch they reference, instead of generically determining it dynamically.

Avatar

Correct answer by
Level 10

Hi,

Using "this.somExpression" will return a string of the full object path;

xfa[0].form[0].topmostSubform[0].Page2[0].Competitions_CB[0].Checkbox[0]

You can also use "xfa.context.somExpression" to return the same thing, using xfa.context is handy when the code is in a script object and called from many object events.

Also, "parent.name" would return the "Competitions_CB" part, so parent.somExpression would return

xfa[0].form[0].topmostSubform[0].Page2[0].Competitions_CB[0]

Regards

Bruce

Avatar

Level 2

Great timing Bruce, thanks, and obvious now you point it out. That saved a lot of manual work I was not looking forward to.