Loading
Feature degradation | Gmail Email delivery failureRead More
Explore Legacy Service Features
Table of Contents
Select Filters

          No results
          No results
          Here are some search tips

          Check the spelling of your keywords.
          Use more general search terms.
          Select fewer filters to broaden your search.

          Search all of Salesforce Help
          Allow Agents to See Their Service Resource Profile with an Apex Trigger

          Allow Agents to See Their Service Resource Profile with an Apex Trigger

          Create an Apex trigger that shares a service resource record with an agent and makes the agent the owner. Agents can then take actions for their own Service Resource record. They can submit a service resource preference, a resource absence, or a time sheet, or see skills that they earned through agent engagement. A trigger allows agents to see only their own Service Resource record, as opposed to opening all Service Resource records publicly to all agents.

          Required Editions

          Note
          Note Workforce Engagement is scheduled for retirement. See Workforce Engagement Retirement.
          View supported editions.

          Here’s an example of how you can share a Service Resource record with an agent.

          Note
          Note To ensure the best outcome with this trigger, ensure that the org-wide default sharing setting for service resource is set to private.
          trigger share_record_with_resource on ServiceResource (after insert) {
              for (ServiceResource sr : Trigger.New) {
                  if (sr.RelatedRecord != null) {
                      ServiceResourceShare srShare = new ServiceResourceShare();
                      srShare.ParentId = sr.Id;
                      srShare.UserOrGroupId = sr.RelatedRecordId;
                      srShare.AccessLevel = 'Read';
                      insert srShare;
                  }
              }
          }
          

          Here's an example of how you could make an agent the owner of a service resource record:

          trigger change_resource_owner on ServiceResource (before insert) {
              for (ServiceResource sr : Trigger.New) {
                  if (sr.RelatedRecordId != null) {
                      sr.OwnerId = sr.RelatedRecordId;
                  }
              }
          }
          
           
          Loading
          Salesforce Help | Article