Expand my Community achievements bar.

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

Prepopulate DDList

Avatar

Level 3

A form with two drop down lists.

First ddlist is called "Model"

List items are: Model1, Model2, Model3, & Model4

Second ddlist is called "Engines"

This has list items: Engine1, Engine2, Engine3, & Engine4.

How can I code this, so that when Model1 is selected in the first ddlist, the second ddlist only has list items "Engine1" & "Engine2" ?

(The only engine options available for Model1)

...and when Model2 is selected in the Model ddlist, the Engine ddlist only displays "Engine3" & "Engine4" ?

Not sure if this requires a script object, or an array of some kind? Either way, I am not sure how to do it, and would love some help from the experts!

Many Thanks

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

The attached contains a sample with linked drop-downs for models and engines as described. It uses a combination of events and a script object.

Steve

View solution in original post

6 Replies

Avatar

Correct answer by
Former Community Member

The attached contains a sample with linked drop-downs for models and engines as described. It uses a combination of events and a script object.

Steve

Avatar

Level 3

Thanks Steve, that exactly what I was trying to do.

Avatar

Level 3

This works fine, but I now need to make a subform visible when a particular engine selection is made.

Because there are no list items (as they are in the script object) is makes it hard to set an action on the engine ddlist to make the subform visible?

I was hoping to do something like:

if (xfa.event.newText == "Engine1") {
  this.resolveNode("subform1").presence = "visible";
}

Avatar

Level 10

Use this script in the layout ready:Event of the subform.

this.presence = DDL.rawValue == "Engine1"? "visible":"hidden";

Avatar

Level 3

Thanks radzmar, but that does not appear to work for me?

Avatar

Level 10

Make sure you use JavaScript as script language.

Also, you may have to use the resolveNode method to resolve the full path of the DDL.

1.  Enter the script into the layoutReady:event of the subform and place the text cursor at the position with the x. (x does not belong to the script)

this.presence = x.rawValue === "Engine1"? "hidden":"visible";

2.  Now press and hold down ctrl + shift and move the mouse cursor over the DDL until a down arrow ˅ will appear, then click the left mouse button.

Designer will add the neccessary part to resolve the path to the DDL to your script.

this.presence = xfa.resolveNode("Form1.#subform.DDL").rawValue === "Engine1"? "hidden":"visible";

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----