Skip to main content
Inspiring
February 29, 2024
解決済み

Populating Company names based of of contract numbers

  • February 29, 2024
  • 返信数 1.
  • 6967 ビュー

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
}

このトピックへの返信は締め切られました。
解決に役立った回答 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

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)

Badhawg66作成者
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 1, 2024

Yes, but move the definition of the "g" variable to the top of the code.