Difference between revisions of "Post Selection JavaScript"

From AgileApps Support Wiki
imported>Aeric
imported>Aeric
Line 27: Line 27:
In the JavaScript code, the following variables are available:  
In the JavaScript code, the following variables are available:  


* <tt>id</tt>: The identifier of the selected record
:* <tt>id</tt>: The identifier of the selected record
* <tt>name</tt>: The label of the selected record
:* <tt>name</tt>: The label of the selected record
* <tt>window.opener.document.mainForm</tt>: The opener form and its fields
:* <tt>window.opener.document.mainForm</tt>: The opener form and its fields


This example displays the label of the selected record.
This example displays the label of the selected record.
Line 36: Line 36:
alert("You have selected record: " + name);</pre>
alert("You have selected record: " + name);</pre>
|}
|}
===Learn More===
===Learn More===
:* [[Field Name|Field Name and Field Value]] syntax
:* [[Field Name|Field Name and Field Value]] syntax

Revision as of 19:07, 28 June 2013

Lookup fields have the additional ability for validations using JavaScript.

Compare to Form Scripting and Field Scripting

Post Selection JavaScript is available in:

  • Custom Objects
  • System Objects:
  • Accounts
  • Templates
  • Contacts
  • Products
  • Contracts
  • Cases
  • Users

Editing Lookup Scripts

Follow these steps to add or change scripting for a lookup field:

  1. Click GearIcon.png > Customization > Objects > {object} > Fields
  2. Click the name of the Lookup field.
  3. Enter or change the code in Post Selection JavaScript.
  4. Click the Save button.

Writing Lookup Scripts

In the JavaScript code, the following variables are available:

  • id: The identifier of the selected record
  • name: The label of the selected record
  • window.opener.document.mainForm: The opener form and its fields

This example displays the label of the selected record.

alert("You have selected record: " + name);

Learn More