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

Apex class with SOQL query to return a list of opportunties based on logged in User Id
Hi Gurus,
I developed an APex class to return a list of opportunities in a particular stage and used this list to display in a visualforce page.
My code:
It is working fine for other users which means else block is working. But it is not showing the list for the user I am checking here. I am using the visualforce page in a visualforce page area and placed it on home page layout for the users
Can any one please help me in this?
Thanks in advance.
I developed an APex class to return a list of opportunities in a particular stage and used this list to display in a visualforce page.
My code:
public with sharing class mycurrentplanningopps { public list <Opportunity> Opp {get; set;} public String UserId {get; set;} public list <Opportunity> getmyincompleteopps() { UserId = UserInfo.getUserId(); if(UserId == '00590000001CxIm') { Opp = [select name,contact_s_Fullname__c,CreatedDate,CloseDate, First_3_stages_of_Audit_pack_up_complete__c, Cancel_any_existing_insurance_cover__c, Complete_any_remaining_rollovers__c, Confirm_if_revenue_has_been_received__c, Ongoing_advice_to_be_implemented__c, Email_the_clients_and_CC_the_planner_in__c, Current_FSG_signed_and_on_file__c, Client_consent_to_prepare_the_SOA__c, Signed_option_to_quote_TFN__c, ATP_Gearing_ATP_if_applicable__c, Signed_Ongoing_advice_authority__c, Copies_of_all_application_held_on_Serve__c, Copy_of_SOA_on_server__c, Copy_of_Fact_find_file_note_on_serve__c, Confirmation_of_transaction_where_online__c,Id from Opportunity where StageName =:'Signed Financial Plan and Insurance']; } else { Opp = [select name,contact_s_Fullname__c,CreatedDate,CloseDate, First_3_stages_of_Audit_pack_up_complete__c, Cancel_any_existing_insurance_cover__c, Complete_any_remaining_rollovers__c, Confirm_if_revenue_has_been_received__c, Ongoing_advice_to_be_implemented__c, Email_the_clients_and_CC_the_planner_in__c, Current_FSG_signed_and_on_file__c, Client_consent_to_prepare_the_SOA__c, Signed_option_to_quote_TFN__c, ATP_Gearing_ATP_if_applicable__c, Signed_Ongoing_advice_authority__c, Copies_of_all_application_held_on_Serve__c, Copy_of_SOA_on_server__c, Copy_of_Fact_find_file_note_on_serve__c, Confirmation_of_transaction_where_online__c,Id from Opportunity where Ownerid =:UserId and StageName =:'Signed Financial Plan and Insurance']; } return Opp; } }
It is working fine for other users which means else block is working. But it is not showing the list for the user I am checking here. I am using the visualforce page in a visualforce page area and placed it on home page layout for the users
Can any one please help me in this?
Thanks in advance.
Use Below Code,
Hope this will help you.
Thanks
karthik
All Answers
I think your Id below should be 18 characters not 15 characters. Can you add debug log and check?
Cheers!!
Nutthawan P.
Use Below Code,
Hope this will help you.
Thanks
karthik
Thanks for your responses guys.
@Karthik your solution worked. Thank you so much.