Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session
SOLVED

A FormCalc Message Box question

Avatar

Former Community Member

Hi there,

I am making message box in formCalc and I would like to set the focus back to the field when the user choose ”yes” .

form1.#subform[0].TextField1::exit - (FormCalc, client)

if(xfa.host.messageBox("Do you want to change the field value?", "Warning", 2, 2)=="4")then

    xfa.host.setFocus($)

endif

I can make the function work in JavaScript but not in FormCalc. Can some tell me whats wrong?

It has to be FormCalc as the message box will pop up at the end of a long complex calculation that I didn’t make. And I don’t have the qualifications (or the time) to change that script to JavaScript.

Kirstine

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

The field name has to be in quotes....

xfa.host.messageBox("TextField1")

Paul

View solution in original post

5 Replies

Avatar

Former Community Member

I assume that you are executing this code on the exit event of the field. If so, then when you exit the field the $ that you are using to refer to the current field is no longer valid. In fact the focus is now the next field so the $ refers to that. Replace the $ with the name of the field that you were on and it should work fine.

Paul

Avatar

Former Community Member

Hi Paul,

I followed your advise but it doesn’t seem to change anything. And yes I am on the exit event.

form1.#subform[0].TextField1::exit - (FormCalc, client)

if(xfa.host.messageBox("Do you want to change the field value?", "Warning", 2, 2)=="4")then

    xfa.host.setFocus(TextField1)

endif

Kirstine

Avatar

Correct answer by
Former Community Member

The field name has to be in quotes....

xfa.host.messageBox("TextField1")

Paul

Avatar

Level 10

Hi,

this should work.

if ($host.messageBox("Do you want to change the field value?", "Warning", 2, 2) eq "4") then

    $host.setFocus($.somExpression)

endif

Avatar

Former Community Member

Paul,

Such a little thing and yet so importent. It works.

Radzmar

I like your script because I don’t have to referre to my field by its exact name. (I may change the name of the field and forget all about the script)

Thanks to both of you.

Kirstine

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