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
Avinash AngasayAvinash Angasay 

Soql/Sosl Related--

Please write queries for these below problems using Sosl and Soql........

How to access notes related to account.
how to compare close date and fiscal year in Sosl.

Thank you in advance..
 
1.) Get all the opportunities,contacts,notes related to an Account where Account Name starts with ‘B’.
 
2.) Get the account name,notes,contacts related to an opportunity where opportunity name ends with ‘A’.
 
3.) Get all the records where field consist ‘Test’ and close date of opportunity records should be of this fiscal year, accounts should be owned by current logged in.
Best Answer chosen by Avinash Angasay
Sai PraveenSai Praveen (Salesforce Developers) 
Hi Avinash,

You can use the below condition in Where Clause.
 
WHERE CloseDate = THIS_FISCAL_YEAR

Let me know if you face any issues.

If this solution helps, Please mark it as best answer.

Thanks,

All Answers

Sai PraveenSai Praveen (Salesforce Developers) 
Hi,

Your SOQL queries for First and second will be as below.
select id,Name,(select id, Name,StageName From Opportunities), (Select id from Notes) ,(Select LastName from Contacts) from Account where Name like 'B%'
select id,Name,Account.name, (Select id from Notes) ,(Select id from OpportunityContactRoles) from Opportunity where Name like '%A'

What do you meant by all records? Do you mean that all Account , Contacts and opportunittes and you have different conditions on each object which may not be possible with SOSL query.

Let me know if you face any issues.

If this solution helps, Please mark it as best answer.

Thanks,
 
Avinash AngasayAvinash Angasay
Thank You For The First And Second Questions Solution .

Get all the records where field consist ‘Test’ and close date of opportunity records should be of this fiscal year.

Just Consider it for a single Object Like Opportunity Only....
All Records Means Opportunity all Records.....
how to Compare close date of opportunity with Fiscal year fiscal year in Where Condition.
 
Sai PraveenSai Praveen (Salesforce Developers) 
Hi Avinash,

You can use the below condition in Where Clause.
 
WHERE CloseDate = THIS_FISCAL_YEAR

Let me know if you face any issues.

If this solution helps, Please mark it as best answer.

Thanks,
This was selected as the best answer