Difference between revisions of "On Change Event Script Example"

From LongJump Support Wiki
imported>Aeric
 
imported>Aeric
(Replaced content with "{{Deprecated AJAX API}} {{Deprecated_page|8.0|80}}")
 
Line 1: Line 1:
Copy and paste the following JavaScript code into the on change event script for the Employee ID field in the Benefits object. This code is intended for use as part of an [[On Change Event Script]].
{{Deprecated AJAX API}}


<pre>
{{Deprecated_page|8.0|80}}
//Login with existing credentials
AjaxInfo.setServerId('{$AppSessionID}');
 
//Define the form that we are currently working with
var form = document.mainForm;
 
//Create a new record
var record = new LongJump.Record();
 
//Set the Object ID to the table where you want to search
record.set('object','1555611998oit1617201617');
 
//Add the field list to be retrieved to the record
record.set('field_list',"record_id,first_name,last_name,security_id_");
 
//Set the filter string
record.set('filter', "employee_id equals'" + form.employee_id.value + "'");
 
//Make the search API call
var result = AjaxAPI.searchRecords(record);
 
//Status returns 'ERROR' when the search record does not retrieve records
//If the searchRecord retrieves a record then the status is set to 'RECORD'
if(result[0].getStatus() != 'RECORD')
{
  alert("Enter a valid 'Employee ID'");
}
 
//Employee found that matched the ID populated in the form
else
{
  form.employee_name.value = result[0].get("first_name") + " " + result[0].get("last_name");
  form.social_security_number.value = result[0].get("security_id_");
}
</pre>

Latest revision as of 00:25, 9 February 2012

Warn.png

DEPRECATED: The AJAX APIs are deprecated. They continue to work, for backward compatibility, but they are not being extended or enhanced. (Web pages should use AJAX and REST to carry on a conversation with the server, rather than the deprecated AJAX APIs.)


For information on this deprecated functionality, see the version 8.0 platform docs:
https://agileappscloud.info/lj80/index.php?title=On_Change_Event_Script_Example