Skip to main content

Notifications

Customer Service forum
Suggested answer

Prevent users from removing someone else's items from queue

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
    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 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
    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

Community Spotlight of the Month

Kudos to Mohamed Amine Mahmoudi!

Blog subscriptions now enabled!

Follow your favorite blogs

TechTalk: How Dataverse and Microsoft Fabric powers ...

Explore the latest advancements in data export and integration within ...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 283,860 Moderator

#2
Ludwig Reinhard Profile Picture

Ludwig Reinhard Microsoft Employee

#3
Martin Dráb Profile Picture

Martin Dráb 225,155 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans