I've got the following function in a script, the f...
# suitescript
m
I've got the following function in a script, the function works fine in both SS2.0 & SS2.1. However, record.attach() doesn't attach my file in SS2.1, but does in SS2.0. Any idea what I'm doing wrong, or if this is a known issue?
Copy code
function createFile(fileContent, filePrefix, recordId, recordType){
		var dtNow = new Date();
		var timestamp = dtNow.getTime();
		var fileName = filePrefix+'_'+timestamp+'.JSON';
		var fcFile = file.create({name: fileName, fileType: 'JSON', contents: fileContent});
			fcFile.folder = getPendingFolderId();
		var fcFileId = fcFile.save();
		record.attach({record: {type: 'file', id: fcFileId}, to: {type: recordType, id: recordId}});
		var response = fileName+' has been generated and placed in the File Cabinet. Please see Communication subtab -> Files sublist to view the file.';
		log.audit('Created file', response);
		return response;
    }