Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

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."); 
}
share|improve this question
add comment

1 Answer 1

up vote 4 down vote accepted

That looks to be a permissions issue. The user making the request needs to have the View Setup and Configuration permission. Otherwise, you'll get that error.

share|improve this answer
    
UGH! I should have known! in soql, I can write userinfo.getProfileId() to get the users profile Id. how do I do that here? –  nivyaj Jul 2 at 18:45
1  
var currentUser = "{!$User.Id}"; var profileId = "{!$Profile.Id}"; –  nivyaj Jul 2 at 19:12
    
Yup, that's it! :) –  Kevin O'Hara Jul 2 at 19:13
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.