/* ----------------------------------------------------------------------------------------------------------------
*	
Function:	fieldChanged

Functionality:
Populates the Bill to address on SO or Invoice with patners Bill To address on click of a chech box.

Deployment:
The script can be deployed on Sales Order or Invoice.

Event triggering the script:
	1) Field change event of a check box.
	

Custom Fields:
+-----------------------------------------------------------------------------------------------------------------+
| S. No.|	Id					|	Type			|	Level	|		Description							
+-----------------------------------------------------------------------------------------------------------------+
| (1)	|	_partnerAddress		|	Free Form Text	|	Body	|	It is sourced from the Bill To field on Partner record  |
| (2)	|	_partneraddchk		|	Check Box		| Check Box | If this check box is clicked ,Partners Bill To address appears in the Bill to field.|

Create above custom fields with their id and type as mentioned in table and declare a global variable called customerAdd.

*------------------------------------------------------------------------------------------------------------------
*/
//Global variables
{
	var debugFieldChange = false;
}
function fieldChanged(type,name)
{
if (name == 'custbody_partneraddchk')
		{
			if (nlapiGetFieldValue('custbody_partneraddchk') == 'T')
			{
				customerAdd = nlapiGetFieldValue('billaddress'); 
				var partnerAdd = nlapiGetFieldValue('custbody_partneraddress');
				if ( debugFieldChange )alert(partnerAdd);
				nlapiSetFieldValue('billaddress',partnerAdd);
			}
			else
				nlapiSetFieldValue('billaddress',customerAdd);
		}
		return true;
}