Expand my Community achievements bar.

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

xfa.host.messageBox

Avatar

Former Community Member

I am trying to get a message to appear if someone tries to enter enter data in a drop down list before entering in formation in a previous list.  I have two drop down lists: ServiceType[0] and Action[0]. I have this code set up in the change event:

topmostSubform.Page2.Action[0]::change - (JavaScript, client)

if

(topmostSubform.Page2.ServiceType[0].rawValue == null)

{

xfa.host.messageBox("You must select a Service Type Value"

, "Error", 3, 1);

}

When I select something from the Action[0] list, nothing happens when I have not selected anything in the ServiceType[0] list. What am I missing please?

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hm,

generally your scripts look fine.

But, JavaScript does not support the instance accessor [0] you used, only FormCalc does.

To use them in JavaScript you need the xfa.resolveNode method like xfa.resolveNode(" topmostSubform.Page2.ServiceType[0]").

Also, to resolve the first instance of an object, which has always the accessor [0], you don't need to describe the accessor.

So topmostSubform.Page2.ServiceType is the same as topmostSubform.Page2.ServiceType[0]

Just a hint for your script in JavaScript.

if (xfa.resolveNode("topmostSubform.Page2.ServiceType").rawValue == "" || xfa.resolveNode("topmostSubform.Page2.ServiceType").rawValue == null) then

     {

     xfa.host.messageBox("You must select a Service Type Value", "Error", 3, 0)

     xfa.host.setFocus("topmostSubform.Page2.ServiceType")

     xfa.event.change = ""

     }

or in FormCalc.

if (topmostSubform.Page2.ServiceType.rawValue == "" or topmostSubform.Page2.ServiceType.rawValue == null) then

     xfa.host.messageBox("You must select a Service Type Value", "Error", 3, 0)

     xfa.host.setFocus("topmostSubform.Page2.ServiceType")

     xfa.event.change = ""

endif

View solution in original post

2 Replies

Avatar

Correct answer by
Level 10

Hm,

generally your scripts look fine.

But, JavaScript does not support the instance accessor [0] you used, only FormCalc does.

To use them in JavaScript you need the xfa.resolveNode method like xfa.resolveNode(" topmostSubform.Page2.ServiceType[0]").

Also, to resolve the first instance of an object, which has always the accessor [0], you don't need to describe the accessor.

So topmostSubform.Page2.ServiceType is the same as topmostSubform.Page2.ServiceType[0]

Just a hint for your script in JavaScript.

if (xfa.resolveNode("topmostSubform.Page2.ServiceType").rawValue == "" || xfa.resolveNode("topmostSubform.Page2.ServiceType").rawValue == null) then

     {

     xfa.host.messageBox("You must select a Service Type Value", "Error", 3, 0)

     xfa.host.setFocus("topmostSubform.Page2.ServiceType")

     xfa.event.change = ""

     }

or in FormCalc.

if (topmostSubform.Page2.ServiceType.rawValue == "" or topmostSubform.Page2.ServiceType.rawValue == null) then

     xfa.host.messageBox("You must select a Service Type Value", "Error", 3, 0)

     xfa.host.setFocus("topmostSubform.Page2.ServiceType")

     xfa.event.change = ""

endif