SOSL CHALLENGE String name='Testing'; Id user=UserInfo.getUserId(); Find : name in ALL FIELDS RETURNING Opportunity (Name where CloseDate = THIS_FISCAL_YEAR), Account (id where OwnerId = :user)
assignment SOSL : string userLogged =userinfo.getUserId(); string toSearch ='Test'; List objList =[FIND :toSearch IN ALL FIELDS RETURNING Opportunity( ID,CloseDate WHERE CloseDate=THIS_FISCAL_YEAR),Account(Id,Name,OwnerId WHERE OwnerId=:userLogged)]; System.debug('objList '+objList);
You can retrieve all fields with SOQL in Apex by Using Record Id ID recordId = '5001a00000CgCE2'; DescribeSObjectResult describeResult = recordId.getSObjectType().getDescribe(); List fieldNames = new List( describeResult.fields.getMap().keySet() ); String query = ' SELECT ' + String.join( fieldNames, ',' ) + ' FROM ' + describeResult.getName() + ' WHERE ' + ' id = :recordId ' + ' LIMIT 1 ' ; // return generic list of sobjects or typecast to expected type List records = Database.query( query ); System.debug( records );
By using SOQL in Apex just like the below example, Id recordId = '00128000002KuXO'; DescribeSObjectResult descResult = recordId.getSObjectType().getDescribe(); List fieldList = new List(descResult.Fields.getMap().keySet()); String query = ' SELECT ' + String.join(fieldList, ',') + ' FROM ' + descResult.getName() + ' WHERE ' + ' id = :recordId'; List records = Database.query(query); System.debug(records) ;
@@SalesforceHulk Honest Feedback - Your tutorials have helped me a lot in the past. But somehow the live tutorials are not that engaging (probably due to constant disturbances and the slow progression of the class.
Day 3 Challenge: public class sosltest { public static void sch(){ List getrec = [Find 'Test' in all Fields Returning Account(id, name where OwnerId= :UserInfo.getUserID()) ,Opportunity(id,name where closedate = THIS_YEAR)]; List acclist = getrec[0]; List opplist = getrec[1]; system.debug(acclist + ' '+ opplist); } }
Assignment:1 [select sum(Amount), status , username, CALENDER_YEAR(created date) from opportunity Where Status=‘closed’ And CALENDER_YEAR(created date) != Date.today And Username=: userinfo.getusername()] Assignment :2 Public class opportunityhelper { Public static void searchopportunityrecord(string first date,string second date) { List lstopty=[ select id, name, createddate from opportunity where Createddate>: firstdate And Createddate
Day 1 recording??? Shrey
Your clearly explained the concepts. Easily understandable. Thank you
thank you shrey
You are "Salesforce Spiderman".........very detailed explanation...can we expect more sir....very useful .....you are the best....Thanks
salesforce spiderman
How can we see the solution of challanges as its not showing in comment section.
Please make more videos on SOSL AND SOQL
SOSL CHALLENGE
String name='Testing';
Id user=UserInfo.getUserId();
Find : name in ALL FIELDS RETURNING Opportunity (Name where CloseDate = THIS_FISCAL_YEAR), Account (id where OwnerId = :user)
assignment SOSL :
string userLogged =userinfo.getUserId();
string toSearch ='Test';
List objList =[FIND :toSearch IN ALL FIELDS RETURNING Opportunity( ID,CloseDate WHERE CloseDate=THIS_FISCAL_YEAR),Account(Id,Name,OwnerId WHERE OwnerId=:userLogged)];
System.debug('objList '+objList);
Hi could you please make a video explaining intergration with examples...
List
Can you teach Salesforce admin plz from beginning
Check out shreysharma.com for a free Salesforce Admin tutorial
How can we retrieve all fields of records using record id.
You can retrieve all fields with SOQL in Apex by Using Record Id
ID recordId = '5001a00000CgCE2';
DescribeSObjectResult describeResult = recordId.getSObjectType().getDescribe();
List fieldNames = new List( describeResult.fields.getMap().keySet() );
String query =
' SELECT ' +
String.join( fieldNames, ',' ) +
' FROM ' +
describeResult.getName() +
' WHERE ' +
' id = :recordId ' +
' LIMIT 1 '
;
// return generic list of sobjects or typecast to expected type
List records = Database.query( query );
System.debug( records );
By using SOQL in Apex just like the below example,
Id recordId = '00128000002KuXO';
DescribeSObjectResult descResult = recordId.getSObjectType().getDescribe();
List fieldList = new List(descResult.Fields.getMap().keySet());
String query = ' SELECT ' + String.join(fieldList, ',') + ' FROM ' + descResult.getName() + ' WHERE ' + ' id = :recordId';
List records = Database.query(query);
System.debug(records) ;
how phone field have a text "John". actually it will only contain numbers. ??? please clarify me hulk
same doubt
Hulk bro your very doing great 👍 job
Thanks!
@@SalesforceHulk Honest Feedback - Your tutorials have helped me a lot in the past. But somehow the live tutorials are not that engaging (probably due to constant disturbances and the slow progression of the class.
Your video is always good, very informative.
I want the first lecture of Salesforce can you please share
ruclips.net/video/ZVNI2ymxPcs/видео.html there you go
Day 3 Challenge:
public class sosltest {
public static void sch(){
List getrec = [Find 'Test' in all Fields Returning Account(id, name where OwnerId= :UserInfo.getUserID())
,Opportunity(id,name where closedate = THIS_YEAR)];
List acclist = getrec[0];
List opplist = getrec[1];
system.debug(acclist + ' '+ opplist);
}
}
Thank you
Assignment:1
[select sum(Amount), status , username, CALENDER_YEAR(created date) from opportunity
Where
Status=‘closed’
And
CALENDER_YEAR(created date) != Date.today
And
Username=: userinfo.getusername()]
Assignment :2
Public class opportunityhelper
{
Public static void searchopportunityrecord(string first date,string second date)
{
List lstopty=[ select id, name, createddate from opportunity where
Createddate>: firstdate
And
Createddate
Hi shrey , please correct me if i am wrong .
I have not executed the code as I don’t have a system at the moment...!