Difference between revisions of "Lookup Post-Selection 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 lookup post-selection event script for the Employee field in the Benefits object. This code is intended for use as part of a [[Lookup Post-Selection Event Script]].
{{Deprecated AJAX API}}


<pre>
{{Deprecated_page|8.0|80}}
alert("You have selected the following Employee from the lookup field :" + name);
alert("The record ID of the employee is : " + id);
alert("The social security of the employee is:" +
    window.opener.document.mainForm.social_security_number.value);
 
//Login: modify the following lines and enter your user name and password
var result1 = AjaxAPI.login('mia@financiocorp.com','yourPlatformName');
alert("Result of login :" + result1.getStatus());
if (result1.getStatus() == 'ERROR')
{
    alert('Login Error, Please provide valid login credentials');
}
else
{
    var userInfo = result1.get('user_info');
    alert('first='+userInfo.get('first_name'));
}
 
//Create a record
var record = new LongJump.Record();
 
//Set the Object ID
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_,employee_type");
 
//Set the filter string
record.set('filter', "record_id equals'" + id + "'");
 
//Make the search API call
var result = AjaxAPI.searchRecords(record);
alert("Search Result: " + result[0].get('message'));
 
//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
{
    alert('Employee you have selected is valid.');
    if((result[0].get('employee_type')) == "Full Time")
    {
        alert("Full Employee selected! \n HMO Benefits will be selected: " +
            result[0].get('employee_type'));
        var form = window.opener.document.mainForm;
        form.benefit_type[0].checked = true;
    }
    else
    {
        alert("Part Employee! \n Only PPO Benefits will be selected : " +
            result[0].get("employee_type"));
        var form = window.opener.document.mainForm;
        form.benefit_type[1].checked = true;
    }
}
</pre>

Latest revision as of 00:24, 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=Lookup_Post-Selection_Event_Script_Example