Expand my Community achievements bar.

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

Copy Text Field To Another

Avatar

Level 3

Hello,


I am trying to copy one text field, EmployeeName, to another, Contacts, for an incident report form I created in LiveCycle.  I am still new with Javascript, and have found this code which I thought would work:

getField("EmployeeName").value == getField("Contacts").valueAsString;

The problem I am facing is that I cannot get it to work.  What I would like to have whatever is typed into the EmployeeName field to also be put into the Contacts field.  I cannot use a global binding as the Contacts will be different than the EmployeeName. 


Any suggestions on what to do?

Thank you,


Justin

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

Hi jrvh924,

Say that your source field path is form.EmployeeName.txtEmpName

Say that your dest. field path is form.Contacts.txtContactName

Then adding the following code should work:

form.Contacts.txtContactName.rawValue = form.EmployeeName.txtEmpName.rawValue;

Please Note : I'm not sure what is wrong with your following script.. Infact, i don't recognize what style of scripting it is. But u can try changing the  = = to = in your following script.

getField("EmployeeName").value = getField("Contacts").valueAsString;

Thanks,

VJ

View solution in original post

3 Replies

Avatar

Correct answer by
Former Community Member

Hi jrvh924,

Say that your source field path is form.EmployeeName.txtEmpName

Say that your dest. field path is form.Contacts.txtContactName

Then adding the following code should work:

form.Contacts.txtContactName.rawValue = form.EmployeeName.txtEmpName.rawValue;

Please Note : I'm not sure what is wrong with your following script.. Infact, i don't recognize what style of scripting it is. But u can try changing the  = = to = in your following script.

getField("EmployeeName").value = getField("Contacts").valueAsString;

Thanks,

VJ

Avatar

Level 3

VJ,


That did it!  I found the script online which, I thought should work, but it did not.  Your code, however, works exactly as I need it to. Thank you!!


Justin         

Avatar

Level 6

That code you found earlier is for a form created in Acrobat, not an XFA form created in LiveCycle Designer, and VJ is right about the correction.

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