Skip to main content

Notifications

Announcements

No record found.

Service | Customer Service, Contact Center, Fie...
Suggested answer

Prevent users from removing someone else's items from queue

Posted on by 57
Hi, is there a way to prevent users from removing other people's items and cases from a queue?
  • Cui Hao Profile Picture
    Cui Hao on at
    Prevent users from removing someone else's items from queue
    Hi,
     
    Did you get a chance to implement the solution I suggested? If any part of the process is unclear, feel free to reach out to me anytime.
     
     
    Best regards,
    Cui Hao
  • Suggested answer
    Cui Hao Profile Picture
    Cui Hao 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
    Cui Hao 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
    YB 57 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
    Cui Hao 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
    Cui Hao 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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans