Expand my Community achievements bar.

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

Passing form field values, to an external script, in a URL

Avatar

Former Community Member

We have a Dynamic, Reader Extended, Livecyce form from which we need to pass two user selected values to an external script. The values need to be passed via a URL, and cannot be static entries, but need to change based on user input.

I have tried variations on the following example, without success.

form1.page1.button::click - (JavaScript, client)

var userselected1;

userselected1 = form1.page1.field1.rawValue;

var userselected2;

userselected2 = form1.page1.field2.rawValue;

xfa.host.gotoURL("http://ourdomain.com/script.php?selected1=userselected1&selected2=userselected2");

Thanks,

Ron

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

Got it!! There is probably a more elegant method for achieving this, but the script below works for us. A new page opens in a browser, and displays information related to the variables passed to the script.

form1.page1.button::click - (JavaScript, client)

newURL1 = 'http://ourdomain.com.com/script.php?selected1=';

newURL2 = userselected1;

newURL3 = "&selected2=";

newURL4 = userselected2;

myNewURL = newURL1+newURL2+newURL3+newURL4;

app.launchURL(myNewURL, true);

Hope this helps someone else!!

View solution in original post

1 Reply

Avatar

Correct answer by
Former Community Member

Got it!! There is probably a more elegant method for achieving this, but the script below works for us. A new page opens in a browser, and displays information related to the variables passed to the script.

form1.page1.button::click - (JavaScript, client)

newURL1 = 'http://ourdomain.com.com/script.php?selected1=';

newURL2 = userselected1;

newURL3 = "&selected2=";

newURL4 = userselected2;

myNewURL = newURL1+newURL2+newURL3+newURL4;

app.launchURL(myNewURL, true);

Hope this helps someone else!!

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] ----