For the life of me, I can't figure out what's going on here. I'm getting a javascript error when the query doesn't return any users. It's coming up sporadically.
what's going on, and what should i do?
error:
A problem with the OnClick JavaScript for this button or link was encountered:
{faultcode:'sf:INVALID_FIELD', faultstring:'INVALID_FIELD:
and id = '005a0000008VBlI') or ( ProfileId = '00e30000000bulF' and
^
ERROR at Row:1:Column:105
No such column 'ProfileId' on entity 'User'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.', detail:{InvalidFieldFault:{exceptionCode:'INVALID_FIELD', exceptionMessage:'
and id = '005a0000008VBlI') or ( ProfileId = '00e30000000bulF' and
^
ERROR at Row:1:Column:105
No such column 'ProfileId' on entity 'User'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.', row:'1', column:'105', }, }, }
code
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
var currentUser = window.UserContext.userId;
var myquery = "select id from user where (userRole.developerName = 'Manager' and id = '" + currentUser + "') or ( ProfileId = '00e30000000bulF' and isActive = true and id = '" + currentUser + "' )";
alert(myquery);
var users= sforce.connection.query(myquery).getArray("records");
var flag = false;
for (var i = 0; i < users.length; i++) {
var user = users[i];
alert("Please wait as the opportunity is getting deleted.");
flag = true;
var result = sforce.connection.deleteIds(['{!Opportunity.Id}']);
location.reload();
}
if (!flag){
alert("Only Data Managers have the ability to delete records.");
}