The following code can be used as a Snippet within the Lawson Smart Office Scripting Tool to add new textboxes.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | /** * AddTextBox - Creates a textbox on the form * Parameters * sName required The unique textbox name * nRow required Numeric row to place the label * nColumn required Numeric column to place the label * nColumnSpan required Numeric column span * bBrowse required Determines if the textbox should be a browse * oAddTo required Where to place label * * Example: AddTextBox("TestBox",1,20,10,false,formGrid) */ private function AddTextBox(sName,nRow,nColumn,nColumnSpan,bBrowse,oAddTo) { if(nColumnSpan < 12){nColumnSpan = 12} // Minumum to show full textbox var textbox1 = new TextBox(); // Create instance of textbox textbox1.Name = sName; // Assign a unique name textbox1.Height = 11; // Set the height // Is this a browse type textbox if(bBrowse == true) { textbox1.Style = StyleManager.StyleTextBoxBrowse; } Grid.SetRow(textbox1, nRow); // Indicate the row Grid.SetColumn(textbox1, nColumn); // Indicate the column Grid.SetColumnSpan(textbox1, nColumnSpan); // Indicate the column span form.AddCustomElement(oAddTo, textbox1); // Where to place the textbox } |
/**
* AddTextBox - Creates a textbox on the form
* Parameters
* sName required The unique textbox name
* nRow required Numeric row to place the label
* nColumn required Numeric column to place the label
* nColumnSpan required Numeric column span
* bBrowse required Determines if the textbox should be a browse
* oAddTo required Where to place label
*
* Example: AddTextBox("TestBox",1,20,10,false,formGrid)
*/
private function AddTextBox(sName,nRow,nColumn,nColumnSpan,bBrowse,oAddTo)
{
if(nColumnSpan < 12){nColumnSpan = 12} // Minumum to show full textbox
var textbox1 = new TextBox(); // Create instance of textbox
textbox1.Name = sName; // Assign a unique name
textbox1.Height = 11; // Set the height
// Is this a browse type textbox
if(bBrowse == true)
{
textbox1.Style = StyleManager.StyleTextBoxBrowse;
}
Grid.SetRow(textbox1, nRow); // Indicate the row
Grid.SetColumn(textbox1, nColumn); // Indicate the column
Grid.SetColumnSpan(textbox1, nColumnSpan); // Indicate the column span
form.AddCustomElement(oAddTo, textbox1); // Where to place the textbox
}Copy the code and save as AddTextbox.jss, for example, or copy directly into the Script tool and Save Selection as Snippet.
