Fix Undefined variable: d in getDataForQueryResource()