at the end you could do: return fileIds.length ?...
# suitescript
c
at the end you could do: return fileIds.length ? fileIds[0] : null;