Expand my Community achievements bar.

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

Trying a set a Text Field value and for it to stick

Avatar

Former Community Member
// At this point tf_Company is " Integral"

xfa.host.messageBox("tf_Company: " + xfa.form.SRF.Page1.tf_Company.rawValue, "Debugging", 3);



// The if statement executes as true

if (dd_Type.rawValue == "M" && tf_Company.rawValue == " Integral")

{

xfa.form.SRF.Page1.tf_Company.rawValue = " TBA";

// At this point " TBA" displays in the form

xfa.host.messageBox("Company has been changed to 'TBA'", "Company",3,0);

};



// At this point tf_Company is null - Why???

xfa.host.messageBox("tf_Company: " + xfa.form.SRF.Page1.tf_Company.rawValue, "Debugging", 3);
4 Replies

Avatar

Level 6
On what event are you running this script? Do you have any calculate scripts on tf_Company that may be changing its value?

Avatar

Former Community Member
At this point it is only on the 'enter' event for dd_Type.

There are no scripts on tf_Company.



Thanks

Avatar

Level 6
Hmmm. I was unable to reproduce the issue. Did you cut and paste the script? If you wrote



if (dd_Type.rawValue == "M" && tf_Company.rawValue = " Integral")



instead of



if (dd_Type.rawValue == "M" && tf_Company.rawValue == " Integral")



that would cause problems. Another thing that I noticed is that you are referencing the fields sometimes by the fully qualified name as in

xfa.form.SRF.Page1.tf_Company.rawValue

but other times as simply

tf_Company.rawValue



Is it possible that you have more than one tf_Company field and you're accidentally referencing the wrong one?



If it's not either of those things, then I suggest you recreate the offending objects in a brand new form and see if it happens there too. Maybe your form has become corrupt somehow. If you do this, don't cut and paste anything from the old form to the new one, since you might copy over whatever's corrupt.

Avatar

Former Community Member
I have solved my problem.



I did make a new (simple) form and everything worked as expected.

So I deleted my tf_Company text field in the original form and re-added it. Again, my tests worked. So somehow, deleting the object and re-adding it made it work (somehow).



Thanks for your help.