change export code to group no app id and null app id together

potentially fixes http://manage.dimagi.com/default.asp?91349