function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
mousetrapmousetrap 

Update Opportunity: Trying to add Owner.Name field

Hi,
 
I'm trying to add the Opportunity Owners Name to the columns available in the Update Opportunity Control. OwnerId works fine but the control locks up as soon as I try adding Owner.Name - which appears to be perfectly workable SOQL.
 
Any ideas?
Ron HessRon Hess
try owner.firstname , owner.lastname

i don't think the owner object has a name member  
rockchick322004rockchick322004
The ability to reference Owner.Name as a merge field requires the ability to "span" objects in merge fields (i.e., your "context" is the Opportunity object.  You can see the Owner.Id because it is a foreign key on Opportunity, but you can not see Owner.Name because that is a field on Owner (well, on User, actually)). 

Spanning objects is currently not supported.  Using SOQL is the workaround.
mousetrapmousetrap

I found the Owner.Name field under the Opportunity.OwnerId which is listed as a reference field.

When I run the query SELECT Owner.LastName FROM Opportunity using Apex Explorer 8.0 I actually get a [drill down] hit which enables me to see the full name.

However, the following code hangs when I include the field reference Owner.LastName:

var showFields = new Array('Owner.Name','AccountId', 'Name','StageName', 'ForecastCategory', 'CloseDate', 'Amount', 'Id');
var queryStr = "select "+showFields.join(", ")+" from opportunity where isclosed = false";

I'm thinking that the reference through the field OwnerId somehow "breaks" the query within the code, even when the SOQL is valid...

 

mousetrapmousetrap
When you say that spanning objects is not supported mscotton, are you sure that SOQL is the solution, my issue seems to be with the code supporting a SOQL statement:
 
var showFields = new Array('Owner.Name','AccountId', 'Name','StageName', 'ForecastCategory', 'CloseDate', 'Amount', 'Id');
var queryStr = "select "+showFields.join(", ")+" from opportunity where isclosed = false";