Expand my Community achievements bar.

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

Highlight Text in FormCalc

Avatar

Level 2

Hi all,

LiveCycle Designer 8.1

I see in the documentation examples of setting the color of a fillable area (background color) of a text field in JavaScript

but I see no example of this in FormCalc. Can any one provide any pointers?

Thanks ~ Ken

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

It is as I suspected .....your script is changing the 1st instance of the field on teh Master Page (on Page 1).

Paul

View solution in original post

11 Replies

Avatar

Level 2

I actually sort of figured this out...but still have a problem.

FormCalc on exit

If the target text field is on the same page, the code below works great:

form1.Win_Opp_3.WO_text2.ui.oneOfChild.border.fill.color.value = "255,255,128";

Unfortunately, my target field is on the Master Page and it will not work. The code I'm using for this is:

form1.#pageSet[0].Page1.mEvaluate.ui.oneOfChild.border.fill.color.value = "255,255,128";

Does anyone know how to do this?

Thanks ~ Ken

Avatar

Former Community Member

The code is fine ...it the reference to yoru field that is the issue. Put this command on the enter event of the field on teh MasterPage    app.alert(this.somExpression)    . Now render your form and enter the field ...the somExpression will appear. That is the reference that you shodul be using. My guess is that there is more than one Page1 instance. Don't forgrt to remove the app.alert on the field when you are finished.

Paul

Avatar

Level 2

pguerett,

I gave that a try:

The alert returned: xfa[0].form[0].form1[0].#pageSet[0].mEvaluate[0]  (I then commented out that code in the Master Page field)

Snap100.jpg

I modified my line of code to: xfa[0].form[0].form1[0].#pageSet[0].Page1[0].mEvaluate[0].ui.oneOfChild.border.fill.color.value = "255,255,128"

The script did not run and said "Error: accessor.....with that line of code"

Interestingly enough, this line of code works in the same script:  form1.#pageSet[0].Page1.mEvaluate = "Yes";  (FormCalc)

I did check and there is only 1 Page 1 instance that I can see

Thanks ~ Ken.

Avatar

Level 2

Paul,

Thanks,

The script is in the last drop-dwon on the last page and the master field in in the header on far right.

One its way...

Thanks so much!   Ken

Avatar

Correct answer by
Former Community Member

It is as I suspected .....your script is changing the 1st instance of the field on teh Master Page (on Page 1).

Paul

Avatar

Level 2

Paul,

Thanks so much. I learned a lot here. Your trick about interrogating the field itself is interesting. i.e - app.alert(this.somExpression)

I now understand what you mean by the Page[ ] reference which I did not get before.

I also now understand the reference to multiple instances of the page...quite interesting. I'm not sure why I can set the rawValue across all pages but not an object attribute ... but I actually see this as a plus as it extends flexibility. Your for loop technique solves the problem nicely.

Thanks for your extended help!

All my best ~ Ken

Avatar

Level 2

Hey Paul,

If you still have that form I sent...one more question which confuses me a bit.

Also in the Master Page, I have a checkbox in the upper right called "Question Num" (checkbox label)

This checbox shows or hides question numbers on the pages.

If I set the colored area in the Master as we were discussing with the drop-down and then check the "Question Num" checkbox, the colored area of the other object goes white. This one is a bit strange.

Any ideas?

Thanks ~ Ken

Avatar

Former Community Member

You can add commands to check th eoriginal color of the field and set it after all th ecode on th echeckbox has been executed. So add this to the end of the checkbox script:

 

var origColor = mEvaluate.ui.oneOfChild.border.fill.color.value

for i=0 upto 13 step 1 do

form1.#pageSet.Page1[i].mEvaluate.ui.oneOfChild.border.fill.color.value = origColor; // Master Page

endfor

Note that you do not neccessarily need the for loop you can do the same thing in formcalc using the * notation for occurances ..like this:

var origColor = mEvaluate.ui.oneOfChild.border.fill.color.value

form1.#pageSet.Page1[*].mEvaluate.ui.oneOfChild.border.fill.color.value = origColor; // Master Page

Paul

Avatar

Level 2

Hi Paul,

For some reason that does not work.

I tried the for loop - seems to have no affect as the colors still blank out

Other ideas?

Thanks ~ Ken

Avatar

Former Community Member

I tried it here and it worked fine ....are you sure you typed it on correctly and put it on the correct event?

paul

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