+ Start a Discussion
sunny.kapoor1306sunny.kapoor1306 

apex

I have developed a page where all users are shown,field i have made is Selected user

Selected user is not working with custom fields but is working with standard fields

 

eg

I wrote Account_Owner__c=:selecteduser;

then its not showing the desired result

 

but when i use createdbyid=:selecteduser;

it shows the record

 

bob_buzzardbob_buzzard

Is Account_Owner__c a lookup to a user object?

Navatar_DbSupNavatar_DbSup

Hi,
Have you created any record in which you have selected the Account_Owner__c??? I don’t think that is not working for custom field. It will work for both.

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

sunny.kapoor1306sunny.kapoor1306

bob_buzzard

 

its a cross-obj formula(text)

sunny.kapoor1306sunny.kapoor1306

Navatar_DbSup

 

there are many records which have account owner

thats what i am saying:when i use standared field equal to selected user it displays the user

but with account owner it isnt

bob_buzzardbob_buzzard

Is it a cross object formula to a user id?

sunny.kapoor1306sunny.kapoor1306

bob_buzzard

 

its a cross object formula for account owner

 

see Mr. Bob

 

I want to show the details of that item where account owner is equal to selected user i.e. the user which i select form the picklist only the account owner=selected user details shud b shown

bob_buzzardbob_buzzard

Understood.  And your cross object formula refers to the OwnerId field?  Also, your picklist has values that are user ids?

sunny.kapoor1306sunny.kapoor1306

bob_buzzard

 

bingo bob

so can u help pe in this?

bob_buzzardbob_buzzard

I've just had a quick play around in my dev org, and it does work when used in this way.  I've created a formula field on opportunity that points the to the account owner id, looked up my user id and then run this code through the 'execute anonymous' feature of the IDE:

 

String userId='00580000001ju2C';

List<Opportunity> opps=[select id, Name from opportunity where account_owner__c=:userId];

 

which returned 37 records.

 

One thing to check - are the user ids that appear in your selectlist 15 or 18 characters?  If its the latter, that may be the problem.  Ids get case insensitized under certain circumstances, and as you will be comparing strings in the query, it won't match.

 

 

sunny.kapoor1306sunny.kapoor1306

bob_buzzard

 

userid is standard field and u r giving name of a proper id

mine is account_owner__c=:=:selectedUser

 

if i use a standard field or write name of a particular user,it works

bob_buzzardbob_buzzard

Mine is too - look at the code I posted - that is comparing a string representation of an id with a formula field, in exactly the way that you have described.

shra1_devshra1_dev

sunny.kapoor1306

 

Can you show the Formula for Account_Owner__c field?

 

i think by seeing that we can help..

 

 

Regards,

Shravan