Copy link to clipboard
Copied
I am working on a custom format script for a dropdown field and i keep getting an error that the script is to long for the dialog box. I am fairly new to this and I think there is a way to write the script below to save time and space. This is just a sample of the entire script.
var f = event.target;var pos = f.currentValueIndices; //position sélectionnée
if (event.value==" Select Wildlife Management Activity")
this.getField("Caption1").value = "";
if (event.value==" Habitat Control - Range Enhancement (Re-seeding)")
this.getField("Caption1").value = "Reseeding for XX with XX\nDate:\nTotal Acres:";
if (event.value==" Habitat Control - Brush Management")
this.getField("Caption1").value = "XX Removal\nDate:\nTotal Acres";
var f = event.target;
var pos = f.currentValueIndices; //position sélectionnée
if (event.value==" Select Wildlife Management Activity")
this.getField("Caption2").value = "";
if (event.value==" Habitat Control - Range Enhancement (Re-seeding)")
this.getField("Caption2").value = "Reseeding for XX with XX\nDate:\nTotal Acres:";
if (event.value==" Habitat Control - Brush Management")
this.getField("Caption2").value = "XX Removal\nDate:\nTotal Acres";
var f = event.target;var pos = f.currentValueIndices; //position sélectionnée
if (event.value==" Select Wildlife Management Activity")
this.getField("TEXT").value = "";
if (event.value==" Habitat Control - Range Enhancement (Re-seeding)")
this.getField("TEXT").value = "Reseeding for XX with XX\nDate:\nTotal Acres:";
if (event.value==" Habitat Control - Brush Management")
this.getField("TEXT").value = "XX Removal\nDate:\nTotal Acres";
Change the default built-in editor to an external text editor. Text editors are not Word or other word processing program. Examples are Textpad or Notepad plus.
Copy link to clipboard
Copied
Change the default built-in editor to an external text editor. Text editors are not Word or other word processing program. Examples are Textpad or Notepad plus.
Copy link to clipboard
Copied
You can shorten your code by using variables. Instead of referring to the same field multiple times like this:
this.getField("Caption1").value = ...
Change it to:
var f1 = this.getField("Caption1");
f1.value = ...
Copy link to clipboard
Copied
If you are trying to see if required fields have been completed, there are other ways that include looping through the fields and testing the "required" property's value and then testing to see if the current value is that same as the field's default value and setting a control flag for later processing or adding the field name to an array of incomplete fields. The number of lines for this type of solution remains the same no matter how many fields are in the form.