You need to sign in to do that
Don't have an account?

sforce.query on User returning neither error nor data
Hi everyone,
I'm trying to use the OwnerId from Opportunity to retrieve the associated ManagerId from the User table, and not having any luck. I've found a few references to similar issues but there must be something I'm still missing.
Here is the code:
conn = sforce.connection;
function get_ManagerID() {
// get_ManagerID retrieves the Manager ID from the Opportunity Owner's user record
var newMgrId = new String;
try {
results = conn.query("SELECT ManagerId from User where Id = '" + {!Opportunity.OwnerId} + "'");
var records = results.getArray("records");
if (records.size == 1) {
salesMgrId = records[0].ManagerId;
alert("Sales Mgr = " + salesMgrId );
} else {
alert("Cannot find Manager record for user: " + ownerId);
}
...
I have a catch(ex) that uses an alert to display any error message, but there isn't any -- the process just hangs.
I've written other (successful) queries on other tables but this is the first time I've seen this particular syntax suggested, putting the id in multiple quotes -- normally, I would use "Select ... where Id = '{!Opportunity.OwnerId}' and ... " (just as an example that goes a bit further, to clarify my use of ' and "). The reference to ownerId refers to a global assignment ownerId = '{Opportunity.OwnerId}'; I would've used that in my query, but it wasn't faring any better.
I've also tried trimming it down to "Select ManagerId from User where Id = '"{!Opportunity.OwnerId}"'" and "Select ManagerId from User where Id = '{Opportunity.OwnerId}'", but none seems to work. The Schema Explorer added "Select u.ManagerId From User u ... and worked fine - inside Eclipse, but not the S-Control.
Let me know your thoughts, and thanks!
I'm trying to use the OwnerId from Opportunity to retrieve the associated ManagerId from the User table, and not having any luck. I've found a few references to similar issues but there must be something I'm still missing.
Here is the code:
conn = sforce.connection;
function get_ManagerID() {
// get_ManagerID retrieves the Manager ID from the Opportunity Owner's user record
var newMgrId = new String;
try {
results = conn.query("SELECT ManagerId from User where Id = '" + {!Opportunity.OwnerId} + "'");
var records = results.getArray("records");
if (records.size == 1) {
salesMgrId = records[0].ManagerId;
alert("Sales Mgr = " + salesMgrId );
} else {
alert("Cannot find Manager record for user: " + ownerId);
}
...
I have a catch(ex) that uses an alert to display any error message, but there isn't any -- the process just hangs.
I've written other (successful) queries on other tables but this is the first time I've seen this particular syntax suggested, putting the id in multiple quotes -- normally, I would use "Select ... where Id = '{!Opportunity.OwnerId}' and ... " (just as an example that goes a bit further, to clarify my use of ' and "). The reference to ownerId refers to a global assignment ownerId = '{Opportunity.OwnerId}'; I would've used that in my query, but it wasn't faring any better.
I've also tried trimming it down to "Select ManagerId from User where Id = '"{!Opportunity.OwnerId}"'" and "Select ManagerId from User where Id = '{Opportunity.OwnerId}'", but none seems to work. The Schema Explorer added "Select u.ManagerId From User u ... and worked fine - inside Eclipse, but not the S-Control.
Let me know your thoughts, and thanks!
Few things to note:
That did it -- thanks for the prompt response!