web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Service | Customer Service, Contact Center, Fie...
Suggested answer

Prevent users from removing someone else's items from queue

(1) ShareShare
ReportReport
Posted on by 27
Hi, is there a way to prevent users from removing other people's items and cases from a queue?
  • Suggested answer
    Cui Hao Profile Picture
    on at
    Prevent users from removing someone else's items from queue
    Hi,
     
    If you have questions feel free to ask me.
    If it solved your problem, please mark it as verified to help other community members find more. 
     
     
    Best regards,
    Cui Hao
     
     
     
  • Suggested answer
    Cui Hao Profile Picture
    on at
    Prevent users from removing someone else's items from queue
    Hi,
     
    I have implemented your needs with the plugin.
    I use the Plugin Registration Tool to register plugins.
     
    The code I wrote has fully realized your needs, you can make reference to it:
     public class PreventRemoveFromQueue : IPlugin
     {
         public void Execute(IServiceProvider serviceProvider)
         {
             ITracingService tracingService = serviceProvider.GetService(typeof(ITracingService)) as ITracingService;
             IPluginExecutionContext context = serviceProvider.GetService(typeof(IPluginExecutionContext)) as IPluginExecutionContext;
             if (context.InputParameters.ContainsKey("QueueItemId"))
             {
                 IOrganizationServiceFactory serviceFactory = serviceProvider.GetService(typeof(IOrganizationServiceFactory)) as IOrganizationServiceFactory;
                 IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
                 try
                 {
                     Guid queueItemId = (Guid)context.InputParameters["QueueItemId"];
                     ColumnSet columns = new ColumnSet();
                     columns.AllColumns = true;
                     Entity queueItem = service.Retrieve("queueitem", queueItemId, columns);
                     if (!queueItem.Attributes.Contains("workerid"))
                     {
                         return;
                     }
                     EntityReference workerRef = (EntityReference)queueItem.Attributes["workerid"];
                    
                     if (workerRef.Id != null && workerRef.Id != context.UserId)
                     {
                         throw new InvalidPluginExecutionException("Not allowed to remove queue items picked by other users!");
                     }
                 }
                 catch (Exception ex)
                 {
                     throw new InvalidPluginExecutionException(ex.Message);
                 }
             }
         }
     }
     
    My code bases the retrieval on the Workby field, only if the item is assigned to a user or not assigned, that user can remove the operation.
    After testing, my code runs successfully and does what you need, but there is still a point where it can be optimized, you can change the retrieve all columns to show retrieve certain columns.
     
     
    If my answer was helpful, please click Like, and if it solved your problem, please mark it as verified to help other community members find more. If you have further questions, please feel free to contact me.

    Best regards,
    Cui Hao
  • YB Profile Picture
    27 on at
    Prevent users from removing someone else's items from queue
    Hi, the goal of using queues is that users can collaborate and work on other people's cases whenever needed. For that reason, I need the users to be able to see other people's cases that are added to the queue and be able to pick them and work on them. So, I don't want to prevent them from seeing other people's items in the queue. I only want to prevent them from removing other people's cases in the queue. Is that possible?
  • Suggested answer
    Cui Hao Profile Picture
    on at
    Prevent users from removing someone else's items from queue
    Hi,
     
    Do you have any other questions?
    If it solved your problem, please mark it as verified to help other community members find more. 
     
     

    Best regards,​​​​​​​
    Cui Hao
  • Suggested answer
    Cui Hao Profile Picture
    on at
    Prevent users from removing someone else's items from queue
    Hi,

    There is no display rule for this Remove button, which proves that as long as you select the record Remove will appear, there is no OOB method to restrict this Remove button.


    I tested it in the direction of security roles and found it to be workable.
    I've given the user all permissions except the delete permission, with User level permissions. Although the user can still Remove at this point, they can't see other people's items in the queue, so they can't Remove someone else's items.


    I hope this helps.



    If my answer was helpful, please click Like, and if it solved your problem, please mark it as verified to help other community members find more. If you have further questions, please feel free to contact me.


    Best regards,
    Cui Hao

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Dynamics 365 Community Update – Sep 16th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard > Service | Customer Service, Contact Center, Field Service, Guides

#1
Jahanvi Profile Picture

Jahanvi 106

#2
Jatin kumar "Mandlay" Profile Picture

Jatin kumar "Mandlay" 9

#3
AbhiShahi Profile Picture

AbhiShahi 5

Featured topics

Product updates

Dynamics 365 release plans