In this example, a new Contact record is created, which has a parent Account. The main phone number and fax number are read from the Account record and inserted into the Telephone and Fax number fields in the Contact record. The user can change the value in the fields before saving if required. In this example, the following assumptions are made:


For more information about locating the module IDs and field names, see "Obtaining Module ID and Field Name Information".
The typical structure of an onCreate query, which reads fields and inserts fields from a parent, is as follows:

function fieldsOnDefault(){ return "MEFIELDNAME";}
function getDefaultValueOfMEFIELDNAME(){ return "MODULEID.MEFIELDNAME" } 


NOTE: The onCreate code is saved in the Module Settings for the Contact module.
An example of a complete onCreate query with header and footer information, which reads fields and inserts fields from a parent, is as follows:

<html><head><title>onCreateExample1</title><script type="text/javascript"> 
function fieldsOnDefault(){ return "CONTPHONE01,CONTFAX01"; }
function getDefaultValueOfCONTPHONE01(){ return "2.ACCTPHONE01" } 
function getDefaultValueOfCONTFAX01(){ return "2.ACCTFAX01" }
</script></head><body></body></html> 


where:

function fieldsOnDefault() { return "CONTPHONE01, CONTFAX01"; }
function getDefaultValueOfCONTPHONE01(){ return "2.ACCTPHONE01" } 
function getDefaultValueOfCONTFAX01(){ return "2.ACCTFAX01" }