rogerb
Scout

Copy from Calculated Field to Multi Line Textbox

I've got a calculated field with a value that I'd like to copy to a multi line text field with a button click in the form. I know that I could do it via workflow but I'd like to do it right in the form if that is possible. Maybe with some javascript magic? All of the search results I find on this show how to do it via workflow. Thanks!

0 Kudos
Reply
13 Replies
emha
Collaborator

Re: Copy from Calculated Field to Multi Line Textbox

0 Kudos
Reply
rogerb
Scout

Re: Copy from Calculated Field to Multi Line Textbox

emha,

I am trying your solution and keep getting 'UpdateTextBox' is undefined when I preview the form. Here is what I am currently doing:

 

1. Modified calculated control formula to this:


UpdateTextBox(<Exististing formula>)

 

2. Added this snippet to Javascript section of form settings (Recipients is the field I want to update with calc field value)

 

function UpdateTextBox(inpval){
NWF$('#'+Recipients).val(inpval);
return inpval;
}

0 Kudos
Reply
rogerb
Scout

Re: Copy from Calculated Field to Multi Line Textbox

What am I doing wrong?

0 Kudos
Reply
emha
Collaborator

Re: Copy from Calculated Field to Multi Line Textbox

it should work this way....

 

hopefuly you haven't taken/copied "<Exististing formula>" literally and you've replaced it with your real formula...

 

have you copied function code to a global scope, ie. out of any function or event handler you might have already had in form settings.

 

have you checked developer consoile for any errors?

0 Kudos
Reply
rogerb
Scout

Re: Copy from Calculated Field to Multi Line Textbox

My existing formula is similar to this:

 

lookup("Field1","ID", parseLookup(ControlName,false), "Recipients")

 

And I put the code in the Javascript section of the form settings as in the attached screenshot.

 

 

 

0 Kudos
Reply
rogerb
Scout

Re: Copy from Calculated Field to Multi Line Textbox

I was getting an error saying "Recipients is undefined" with this code. So I used the "Insert Reference" to put the Recipients field in the code. And now it's back to the "UpdateTextBox is undefined" error.

0 Kudos
Reply
jackgelo
Contributor

Re: Copy from Calculated Field to Multi Line Textbox

Have you set "Recipients" as you javascript variable ID in the field settings? It should be under Advanced properties

0 Kudos
Reply
rogerb
Scout

Re: Copy from Calculated Field to Multi Line Textbox

Jack,

I got this copied over to a dev environment so I can save my work and not disrupt the live form that people are using.

 

I put "Recipients" in the javascript variable fields. That didn't seem to have any effect.

0 Kudos
Reply
rogerb
Scout

Re: Copy from Calculated Field to Multi Line Textbox

emha,

I opened the developer console, no errors. The only warning was this:

 

"The code on this page disabled back and forward caching"

0 Kudos
Reply