Skip to main content
Inspiring
February 29, 2024
Answered

Populating Company names based of of contract numbers

  • February 29, 2024
  • 1 reply
  • 7022 views

Can someone teach me what is wrong with this script? It says there's an unterminated string literal on line 3. When a user enters a contract number in Field1, I want the form to populate the name of the company the contract is tied to in the field this script is in.

 

var f = this.getField("Field1")

if(event.value == "Contract Number”)

f.value = "Company Name";

else
{
// do nothing
}

This topic has been closed for replies.
Correct answer try67

I want the user to only enter one contract number in Field1 so only one company name populates the field where we put this script.


Use this:

 

var f = this.getField("Field1")
if (event.value == "Contract Number1") {
	f.value = "Company Name1";
} else if (event.value == "Contract Number2") {
	f.value = "Company Name2";
} else {
	// do nothing
}

1 reply

try67
Community Expert
Community Expert
February 29, 2024

You must only use straight quotes, not curly ones, like at the end of this line:

if(event.value == "Contract Number)

Badhawg66Author
Inspiring
March 1, 2024

How would I populate the names of several companies using their contract number? Should I do something like this?

 

var f = this.getField("Field1")

if(event.value == "Contract Number1”)

f.value = "Company Name1";

var g = this.getField("Field1")

if(event.value == "Contract Number2”)

g.value = "Company Name2";

else
{
// do nothing
}

try67
Community Expert
Community Expert
March 4, 2024

I cut everything from the calculation script and pasted it in the validation script

 

I copied a contract number from the validation script and clicked out but it didn't populate

When I clicked the field it does nothing

I put this code in the validation script but it didn't work

 

var a = this.getField("ROW Contract No")

var b = this.getField("ROW Contract No")

var c = this.getField("ROW Contract No")

var d = this.getField("ROW Contract No")

var e = this.getField("ROW Contract No")

var f = this.getField("ROW Contract No")

var g = this.getField("ROW Contract No")

var h = this.getField("ROW Contract No")

var l = this.getField("ROW Contract No")

var j = this.getField("ROW Contract No")

var k = this.getField("ROW Contract No")

if(event.value == "RW-2368A")

a.value = "AG3 GROUP";

if(event.value == "RW-2368B")

b.value = "ATKINS GLOBAL, INC";

if(event.value == "RW-2368C")

c.value = "BENCHMARK, LLC";

if(event.value == "RW-2368D")

d.value = "BENHAM DESIGN, LLC";

if(event.value == "RW-2368E")

e.value = "EST, INC";

if(event.value == "RW-2368F")

f.value = "HUDSON & PRINCE, PLLC";

if(event.value == "RW-2368G")

g.value = "KIETHLINE ENGINEERING, LLC";

if(event.value == "RW-2368H")

h.value = "LEADS, LLC";

if(event.value == "RW-2368L")

l.value = "TEIM DESIGN, PLLC";

if(event.value == "RW-2368J")

j.value = "POE & ASSOCIATES, INC";

if(event.value == "RW-2368K")

k.value = "REDFIRE ENGINEERING, LLC";

else

{

// do nothing

 

I'm not sure what to do 😅


There's no need to define a separate variable for each condition. One is enough.

But it looks like the field you're placing the code under is "ROW Contract No"... It should be the other way around. Or you should change your code to point to the text field you want to populate.