/**
* data - passed in object
* switch - get file extension if there is one
* nlapiCreateFile - create file in File Cabinet
* nlapiAttachRecord - attach file to record
*/
function StoreAttachFile(data)
{
var record_type = data.recordType
var record_id = data.recordId;
...