• Our Man In Bananas
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 7
    Questions
  • 4
    Replies
I am using the below code to get the members of a public group, plus all the indirect members (either members of a child group, or associated by their role membership)
 
public class GetAllGroupMembers {
    
        public static Set<id> GetUserIdsFromGroup(Id groupId)
        {
        // store the results in a set so we don't get duplicates
        Set<Id> result=new Set<Id>();
        String userType = Schema.SObjectType.User.getKeyPrefix();
        String groupType = Schema.SObjectType.Group.getKeyPrefix();
        
        // Loop through all group members in a group
        for (GroupMember m : [Select Id, UserOrGroupId From GroupMember Where GroupId = :groupId])
        {
            // If the user or group id is a user
            if (((String)m.UserOrGroupId).startsWith(userType))
            {
                system.debug('its a user:');
                result.add(m.UserOrGroupId);
                }
            // If the user or group id is a group
            // Note: there may be a problem with governor limits if this is called too many times
            else if (((String)m.UserOrGroupId).startsWith(groupType))
            {
                system.debug('its a Group:');
                // Call this function again but pass in the group found within this group
                result.addAll(GetUSerIdsFromGroup(m.UserOrGroupId));
                }
            }    
            return result;
        }
        
        public static Set<id> GetUserIdsFromGroupWithProxies(Set<Id> groupIds){
            
            system.debug('GetUserIdsFromGroupWithProxies: ');            
        
            // store the results in a set so we don't get duplicates
            Set<Id> result=new Set<Id>();
        
            String userType = Schema.SObjectType.User.getKeyPrefix();
            String groupType = Schema.SObjectType.Group.getKeyPrefix();
           
            Set<Id> groupIdProxys = new Set<Id>();
            
            // Loop through all group members in a group
            for(GroupMember m : [Select Id, UserOrGroupId From GroupMember Where GroupId in :groupIds]){
                // If the user or group id is a user
                if(((String)m.UserOrGroupId).startsWith(userType)){            
                    system.debug('Group Member ' + string.valueOf(m.UserOrGroupId) + ' is a user');
                    result.add(m.UserOrGroupId);
                    }
            
                // If the user or group id is a group
                // Note: there may be a problem with governor limits if this is called too many times
                else if (((String)m.UserOrGroupId).startsWith(groupType)){
                
                    system.debug('Group Member ' + string.valueOf(m.UserOrGroupId) + ' is a group');
                    // Call this function again but pass in the group found within this group
                    groupIdProxys.add(m.UserOrGroupId);
                    }
                }
            
            if(groupIdProxys.size() > 0){
                system.debug('adding ' + groupIdProxys.size() + ' proxies');
                result.addAll(GetUserIdsFromGroupWithProxies(groupIdProxys));
                }
        
            return result;  
        }    
    }
The problem I am facing is that we specifically want to exclude those users who are members because they are the manager of a member...

In SalesForce when I look at Setup > Users > Public Groups > Group_Name > View all users I can see this column:
User-added image

Is it possible to access that information through the api?

If not, how can I restrict or exclude members who are in the group because they are the manager of a member?
I need to lock a record in my trigger after a member of the systems team has changed it.
I tried this code:
// Lock the request
Approval.lock(rq.Id);
rq is the record in my custom object.

The error I get is:
Apex trigger System_Change_Request_Events caused an unexpected exception, contact your administrator: System_Change_Request_Events: execution of BeforeUpdate caused by: System.UnexpectedException: null: Trigger.System_Change_Request_Events: line 315, column 1
line 315 is the one above that tries to lock the record.
It saved the trigegr changes ok, so the method signature must be correct.

I need to lock the record as once this part of the process has been reached there should never be any need to edit it.
But it has to be unlocked after it has been approved by the Line manager in order that systems can convert the request into a demand (by changing the status which kicks off the BeforeUpdate trigger).

in the Process Automation Settings this has been enabled
So what am I missing here and what is the correct way to do this in Apex?
Hi,
I am building a VF page for my custom object Change Request.

In my object trigger on Save, I populate the Manager field of the record with this code:
if (trigger.isBefore && (trigger.isInsert || trigger.isUpdate))
    {
          system.debug('step 3 - set Manager ID & department name');
          
          for (Request_for_System_Change__c r : Trigger.new) {
              
                  string LineManagerid = [SELECT Id, ManagerId from User where Id =: r.OwnerId].ManagerId;
                  string DeptName = [SELECT Id, Department from User where Id =: userinfo.Getuserid()].Department;
                  r.Manager__c = LineManagerId;  
                  r.Department_Name_String__c = DeptName;             
          }         
        }
an that works fine.

So now I am building a VF page I need to do something similar but in my extension class as currently it just shows the manager ID like this "Manager: 009w0000003LRsuAAZ".

So at the top of my VF page I have:
<apex:page id="ChangeRequest" StandardController="Request_for_System_Change__c" extensions="RequestForSystemChangeController"
           standardStylesheets="false" 
			showHeader="false"  >
and the field is defined like this:
<apex:pageBlockSectionItem>
    <apex:outputLabel value="Manager: "/>
        <apex:panelGrid columns="1">
            <apex:outputText value="{!get_Manager(Request_for_System_Change__c.Owner__c)}"/>
         </apex:panelGrid>
</apex:pageBlockSectionItem>
In my extension class I have this method to get the Manager from the User object:
public string get_Manager(string owner_id){
	string LineManagerid = [SELECT Id, ManagerId from User where Id =: owner_id].ManagerId;
//      string LineManagerid; // = [SELECT Id, ManagerId from User where Id =:ApexPages.currentPage().getParameters().get(‘Manager_id’)];
        string DeptName = [SELECT Id, Department from User where Id =: userinfo.Getuserid()].Department;
        return LineManagerId;  
                  //r.Department_Name_String__c = DeptName;                  
    }
But I am getting an error: Unknown function get_Manager. Check spelling.

so what is the correct way to do this, and where am I going wrong?



 
I am a beginner with VisualForce pages, and a 2 week developer with SalesForce custom objects and APEX triggers/classes.

I have built a custom object called **Change Request** (with API name `Request_for_System_Change__c`), with 3 record types.

I now need to write a VisualForce page that will replicate all of the functionality of the default page, but use the styles of my org.

So I have taken the Master layout VF page provided by my org, and started to add my fields to it in the section 'Show Main data in the main panel' in the code below.

I am a little confused however about the mechanics of this.

I get that I can use `<apex:outputField value=` for each of the standard and custom fields in my custom object in display view, and use a form with `<apex:inputField` elements (with HTML `<Div>` and `<Table>` etc) and I guess I control which fields are displayed using the `render` attribute based on a mode variable, but how will I tell my standard controller that

 1. should I put all the fields for **New/Edit** and **View** modes on the same page
 2. How will I switch between modes?
 3. How would I tell the standard controller to show a list of exiting records and to display an existing records, edit an existing record for Update or **Submit for Approval**

Here is the code I have so far (in the section Show Main data in the main panel):
 
<apex:page id="CIF_Application" StandardController="Request_for_system_Change__c"
       standardStylesheets="false"
       showHeader="false"  >
   
    <head>
    <title>Change Requests </title>
    </head>
   
    <meta http-equiv="X-UA-Compatible" content="IE=10" />
   
      <apex:stylesheet value="{!URLFOR($Resource.BCSitesStyles, 'sifr3.css')}"/>
      <apex:includeScript value="{!URLFOR($Resource.BCSitesScripts, 'sifr3.js')}"/>
      <apex:includeScript value="{!URLFOR($Resource.BCSitesScripts, 'sifr-config.js')}"/>   
   
    <apex:composition template="cif_Layout" >
   
    <apex:define name="Title">
     Change Request1
    </apex:define>
   
    <apex:define name="PageStatus" >
     <apex:actionStatus startstyleClass="popupBackgroundStatusStart" stopstyleClass="popupBackgroundStatusStop"   id="MainStatustmp">
      <apex:facet name="start">
       <apex:image value="{!$Resource.AjaxIcon}" />
      </apex:facet>
     </apex:actionStatus>
   
    </apex:define>  
         
    <!-- ------------------------------------------------------------ -->
    <!-- Top Horizontal Menu  -->
    <!-- ------------------------------------------------------------ -->
    <apex:define name="NavTool" >
     
      <apex:outputpanel id="NavPanel" rendered="true">
      <div id="TopToolBar" style="margin-left: -20px">   
      <apex:actionStatus startstyleClass="popupBackgroundStatusStart" stopstyleClass="popupBackgroundStatusStop"   id="NavStatus" />
      
       <c:cCif_Application_Navbar />         
      </div>
         </apex:outputpanel> 
    </apex:define>
   
    <!-- ------------------------------------------------------------ -->
    <!-- Side bar Navigation section (show Stage of the Application) -->
    <!-- ------------------------------------------------------------ -->
    <apex:define name="SideBar_Navigation">
     <c:cCIF_Application_Sidebar ActiveNavOption="1" mode="Console"/>
    </apex:define>
   
    <!-- ------------------------------------------------------------ -->
    <!-- Side bar Messages section (show Messages of the Application) -->
    <!-- ------------------------------------------------------------ -->
    <apex:define name="SideBar_Messages">
        <c:cCif_User_Info_Panel /> 
    </apex:define>   
         
    <!-- ------------------------------------------------------------ -->
    <!-- Shows Customer Name and Application Number top left of main Panel -->
    <!-- ------------------------------------------------------------ -->
    <apex:define name="Customer_Application_Name">
     
    </apex:define>
   
    <!-- ------------------------------------------------------------ -->
    <!-- Show Main data in the main panel -->
    <!-- ------------------------------------------------------------ -->
    <apex:define name="Main_Panel">
     <br/>
      <div class="mainpanelwidget OneMainPanel MainPanelTitlePadding" style="padding-right: 10px;">
     <table border="" style="width:100%; padding:3px" >
      <tr>
       <td>
       <font class="bocTextBold">Service Announcements</font>
        
       </td>
      <td>
       
      </td>
      </tr>
     </table>
        <apex:pageBlock title="Basic information">
           
            <apex:pageMessages />
            <apex:pageBlockSection columns="1" >
                <apex:outputField value="{! Request_for_System_Change__c.Request_Title__c }"/>
                <apex:outputField value="{! Request_for_System_Change__c.RecordTypeId }"/>
                <!--apex:outputField value="{! Request_for_System_Change__c.Owner }"/-->
                <apex:outputField value="{! Request_for_System_Change__c.Status__c }"/>
                <apex:outputField value="{! Request_for_System_Change__c.Request_Priority__c }"/>
                <apex:outputField rendered="{!Request_for_System_Change__c.Request_Priority__c=='High'}"
                                  value="{! Request_for_System_Change__c.Reason_for_High_priority__c }"/>
            </apex:pageBlockSection>
            <apex:pageBlockSection columns="2" >
                 <apex:outputField value="{! Request_for_System_Change__c.Department_Requested_by__c }"/>
                <apex:outputField value="{! Request_for_System_Change__c.Description_of_change_requested__c }"/>
                 <apex:outputField value="{! Request_for_System_Change__c.Reason_for_data_request__c }"/>
                <apex:outputField value="{! Request_for_System_Change__c.Systems_Affected__c }"/>
                <apex:outputField value="{! Request_for_System_Change__c.Manager__c }"/>
                <apex:outputField value="{! Request_for_System_Change__c.Date__c }"/>
                 <apex:outputField value="{! Request_for_System_Change__c.Are_Customers_affected_by_this_change__c }"/>
                <apex:outputField value="{! Request_for_System_Change__c.Additional_information_comments__c }"/>
     <apex:outputField value="{! Request_for_System_Change__c.Benefits_Reasons__c }"/>
                <apex:outputField value="{! Request_for_System_Change__c.New_data_to_be_captured__c }"/>
     <apex:outputField value="{! Request_for_System_Change__c.Legal_Regulatory_Compliance_impact__c }"/>
                <apex:outputField value="{! Request_for_System_Change__c.Related_Committee_paper_or_action_point__c }"/>                     
            </apex:pageBlockSection>
        </apex:pageBlock>
    <apex:pageblocksection columns="1" id="pbs1" rendered="{!Request_for_System_Change__c.recordType == 'System Change Request'}">
         <apex:detail />
    </apex:pageblocksection>  
     </div>
    </apex:define>
   
    <!-- ------------------------------------------------------------ -->
    <!-- Show buttons for the page -->
    <!-- ------------------------------------------------------------ -->
    <apex:define name="Control_Panel">
     
     <!-- PUT BUTTONS IN HERE -->
     
    </apex:define>
       </apex:composition>
       </apex:page>

   
we have created a custom object called "Request for System Change" (API name **Request_for_System_Change__c**) and a trigger that runs when the approval process sets the status to "Approved".

The trigger creates a new record on another custom object called "Demand"

This is the only Apex code I have, but I need to write a test method that will update the status of an existing *Request for System Change* record, setting it's status to **New**. This should kick off the trigger, creating a new record on the *Demand* object...

Here is my trigger:
trigger SystemChangeRequest on Request_for_System_Change__c (after update, before insert, before update) {

    system.debug('step 1');
    string systemChangeRecordType = Schema.SObjectType.Request_for_System_Change__c.getRecordTypeInfosByName().get('System Change Request').getRecordTypeId();
   
    string mailshotDataRequestRecordType
         = Schema.SObjectType.Request_for_System_Change__c.getRecordTypeInfosByName().get('Mailshot data request').getRecordTypeId();
   
    string dataRequestAndApprovalRecordType
         = Schema.SObjectType.Request_for_System_Change__c.getRecordTypeInfosByName().get('Data request and approval').getRecordTypeId();

    system.debug('recort type = '+ systemChangeRecordType);       
    system.debug('step 2');
   
    if (trigger.isBefore && (trigger.isInsert || trigger.isUpdate))
    {
          system.debug('step 3 - set Manager ID & department name');
         
          for (Request_for_System_Change__c r : Trigger.new) {
             
              string LineManagerid = [SELECT Id, ManagerId from User where Id =: r.OwnerId].ManagerId;
              string DeptName = [SELECT Id, Department from User where Id =: userinfo.Getuserid()].Department;
              r.Manager__c = LineManagerId; 
              r.Department_Name_String__c = DeptName;        
              }        
        }
   
    if (Trigger.IsUpdate && trigger.isbefore)
    {
        Boolean convertToDemand=false;
       
        for (Request_for_System_Change__c rq : Trigger.new) {
           
            system.debug('step 4a Record Type='+rq.RecordType.Name);
           
            // Access the "old" record by its ID in Trigger.oldMap
            Request_for_System_Change__c oldrecord = Trigger.oldMap.get(rq.Id);

            system.debug('get LineManagerName');
            string lineManagerName = [SELECT Name from User where Id =: rq.Manager__c].Name;
            system.debug('Line Manager name for Demand: ' + lineManagerName);          
          
            if (rq.Status__c != OldRecord.Status__c && rq.Status__c == 'Approved' && rq.RecordTypeId == systemChangeRecordType )
                        {
                system.debug('step 4b - Approved and create demand for '+ systemChangeRecordType);
               
                apm2__Demand__c newD = new apm2__Demand__c();
               
                newD.Demand_request_date__c = rq.Date__c;
                newD.Project_Department__c = 'Systems';
                newD.Demand_Title__c = rq.Request_Title__c;
                newD.apm2__Criticality__c = rq.Request_Priority__c;
                newD.Demand_Requested_by__c = lineManagerName;
                newD.Prioritisation_points__c = rq.Benefits_Reasons__c;
                newD.Demand_request_date__c = system.today();
                newD.apm2__Business_Driver__c = rq.Benefits_Reasons__c;
                newD.Demand_Status__c = 'New';
                newD.apm2__Description__c = rq.Description_of_change_requested__c;
                newD.Additional_Information__c = rq.Anticipated_benefits_reason_for_change__c + ' \r\n' + rq.Additional_information_comments__c;
                newD.Department_Requested_by__c = rq.Department_Requested_by__c;
                newD.Systems_Affected__c=rq.Systems_Affected__c;
               
                insert newD;
                rq.Demand__c = newD.Id;
            }
        }
    }
I have an existing record, which has a SalesForce ID (like 'x2T55000000D2hp') (and the record ID within the object is **R-1512027**)

So now I need to write a test method that will get that existing record, and update the status to "New"

Here is where I am stuck:
@isTest
    public class SystemChangeRequestTest {
     static testMethod void myUnitTest()
        {
            // get record based on SF ID
            Schema.SObjectType.Request_for_System_Change__c.getRecord req = Trigger.newMap.get('x2T55000000D2hp');
   
            // x2T55000000D2hp
            // R-1512027
           
        }   
    }
I have an *invalid type* error where I am trying to get the record

What is the correct way to do this?
I have the below trigger in my custom object. When a record is saved, the Manager field is being updated (via a lookup against the userInfo object)
trigger trg_LineManager on Request_for_System_Change__c (after insert, after update, before insert, before update) {

string LineManagerid = [SELECT Id, ManagerId from User where Id =: userinfo.Getuserid()].ManagerId;
    if (trigger.isBefore && (trigger.isInsert || trigger.isUpdate))
    {   
          for (Request_for_System_Change__c r : Trigger.new) {
                    
            r.Manager__c = LineManagerId;           
          } 
    }    
}



It works fine, except that when another user edits an existing record, the Manager field is being updated again with the current users manager.

So in fact I should be getting the Manager of the record Owner rather than the Mnaager of the current user.
Hi,
I am trying the Trailhead challange for Formula fields at https://developer.salesforce.com/trailhead/point_click_business_logic/formula_fields#challenge

and the challenge is to add a formula field on the Case object referencing the Last Activity Date of the Account object.

But the Account object doesn't have a Last Activity Date (and neither does the Case object) - so how can I complete that challenge?
I am using the below code to get the members of a public group, plus all the indirect members (either members of a child group, or associated by their role membership)
 
public class GetAllGroupMembers {
    
        public static Set<id> GetUserIdsFromGroup(Id groupId)
        {
        // store the results in a set so we don't get duplicates
        Set<Id> result=new Set<Id>();
        String userType = Schema.SObjectType.User.getKeyPrefix();
        String groupType = Schema.SObjectType.Group.getKeyPrefix();
        
        // Loop through all group members in a group
        for (GroupMember m : [Select Id, UserOrGroupId From GroupMember Where GroupId = :groupId])
        {
            // If the user or group id is a user
            if (((String)m.UserOrGroupId).startsWith(userType))
            {
                system.debug('its a user:');
                result.add(m.UserOrGroupId);
                }
            // If the user or group id is a group
            // Note: there may be a problem with governor limits if this is called too many times
            else if (((String)m.UserOrGroupId).startsWith(groupType))
            {
                system.debug('its a Group:');
                // Call this function again but pass in the group found within this group
                result.addAll(GetUSerIdsFromGroup(m.UserOrGroupId));
                }
            }    
            return result;
        }
        
        public static Set<id> GetUserIdsFromGroupWithProxies(Set<Id> groupIds){
            
            system.debug('GetUserIdsFromGroupWithProxies: ');            
        
            // store the results in a set so we don't get duplicates
            Set<Id> result=new Set<Id>();
        
            String userType = Schema.SObjectType.User.getKeyPrefix();
            String groupType = Schema.SObjectType.Group.getKeyPrefix();
           
            Set<Id> groupIdProxys = new Set<Id>();
            
            // Loop through all group members in a group
            for(GroupMember m : [Select Id, UserOrGroupId From GroupMember Where GroupId in :groupIds]){
                // If the user or group id is a user
                if(((String)m.UserOrGroupId).startsWith(userType)){            
                    system.debug('Group Member ' + string.valueOf(m.UserOrGroupId) + ' is a user');
                    result.add(m.UserOrGroupId);
                    }
            
                // If the user or group id is a group
                // Note: there may be a problem with governor limits if this is called too many times
                else if (((String)m.UserOrGroupId).startsWith(groupType)){
                
                    system.debug('Group Member ' + string.valueOf(m.UserOrGroupId) + ' is a group');
                    // Call this function again but pass in the group found within this group
                    groupIdProxys.add(m.UserOrGroupId);
                    }
                }
            
            if(groupIdProxys.size() > 0){
                system.debug('adding ' + groupIdProxys.size() + ' proxies');
                result.addAll(GetUserIdsFromGroupWithProxies(groupIdProxys));
                }
        
            return result;  
        }    
    }
The problem I am facing is that we specifically want to exclude those users who are members because they are the manager of a member...

In SalesForce when I look at Setup > Users > Public Groups > Group_Name > View all users I can see this column:
User-added image

Is it possible to access that information through the api?

If not, how can I restrict or exclude members who are in the group because they are the manager of a member?
Hi,
I am building a VF page for my custom object Change Request.

In my object trigger on Save, I populate the Manager field of the record with this code:
if (trigger.isBefore && (trigger.isInsert || trigger.isUpdate))
    {
          system.debug('step 3 - set Manager ID & department name');
          
          for (Request_for_System_Change__c r : Trigger.new) {
              
                  string LineManagerid = [SELECT Id, ManagerId from User where Id =: r.OwnerId].ManagerId;
                  string DeptName = [SELECT Id, Department from User where Id =: userinfo.Getuserid()].Department;
                  r.Manager__c = LineManagerId;  
                  r.Department_Name_String__c = DeptName;             
          }         
        }
an that works fine.

So now I am building a VF page I need to do something similar but in my extension class as currently it just shows the manager ID like this "Manager: 009w0000003LRsuAAZ".

So at the top of my VF page I have:
<apex:page id="ChangeRequest" StandardController="Request_for_System_Change__c" extensions="RequestForSystemChangeController"
           standardStylesheets="false" 
			showHeader="false"  >
and the field is defined like this:
<apex:pageBlockSectionItem>
    <apex:outputLabel value="Manager: "/>
        <apex:panelGrid columns="1">
            <apex:outputText value="{!get_Manager(Request_for_System_Change__c.Owner__c)}"/>
         </apex:panelGrid>
</apex:pageBlockSectionItem>
In my extension class I have this method to get the Manager from the User object:
public string get_Manager(string owner_id){
	string LineManagerid = [SELECT Id, ManagerId from User where Id =: owner_id].ManagerId;
//      string LineManagerid; // = [SELECT Id, ManagerId from User where Id =:ApexPages.currentPage().getParameters().get(‘Manager_id’)];
        string DeptName = [SELECT Id, Department from User where Id =: userinfo.Getuserid()].Department;
        return LineManagerId;  
                  //r.Department_Name_String__c = DeptName;                  
    }
But I am getting an error: Unknown function get_Manager. Check spelling.

so what is the correct way to do this, and where am I going wrong?



 
I have the below trigger in my custom object. When a record is saved, the Manager field is being updated (via a lookup against the userInfo object)
trigger trg_LineManager on Request_for_System_Change__c (after insert, after update, before insert, before update) {

string LineManagerid = [SELECT Id, ManagerId from User where Id =: userinfo.Getuserid()].ManagerId;
    if (trigger.isBefore && (trigger.isInsert || trigger.isUpdate))
    {   
          for (Request_for_System_Change__c r : Trigger.new) {
                    
            r.Manager__c = LineManagerId;           
          } 
    }    
}



It works fine, except that when another user edits an existing record, the Manager field is being updated again with the current users manager.

So in fact I should be getting the Manager of the record Owner rather than the Mnaager of the current user.
Hi,
I am trying the Trailhead challange for Formula fields at https://developer.salesforce.com/trailhead/point_click_business_logic/formula_fields#challenge

and the challenge is to add a formula field on the Case object referencing the Last Activity Date of the Account object.

But the Account object doesn't have a Last Activity Date (and neither does the Case object) - so how can I complete that challenge?
Apex Basics & Database Unit 5/5

Hello, Community, I am facing problem in solving this challenge, please advise.

Here is the criteria presented: 

With SOSL you can search against different object types that may have similar data, such as contacts and leads. To pass this challenge, create an Apex class that returns both contacts and leads that have first or last name matching the incoming parameter.

The Apex class must be called 'ContactAndLeadSearch' and be in the public scope.
The Apex class must have a public static method called 'searchContactsAndLeads'.
Because SOSL indexes data for searching, you must create a Contact record and Lead record before checking this challenge. Both records must have the last name 'Smith'. The challenge uses these records for the SOSL search.
The return type for 'searchContactsAndLeads' must be 'List<List< SObject>>'
The 'searchContactsAndLeads' method must accept an incoming string as a parameter, find any contact or lead that matches the string as part of either the first or last name and then return those records.

Error received: 

Challenge not yet complete... here's what's wrong: 
Executing the 'searchContactsAndLeads' method failed. Either the method does not exist, is not static, or does not return the expected search results.

Here is my code:

public class ContactAndLeadSearch{
    public static List<List< SObject>> searchContactsAndLead(String name)
    {
        List<List<sObject>> result=[FIND :name IN ALL FIELDS RETURNING Lead(LastName),Contact(LastName)];
                return result;
    }
}


PLEASE ADVISE...Thanks Community!!!