function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Puja Gupta 18Puja Gupta 18 

How to assign case to logged in user instead of default case owner ?

Hello 

My query is if case is genrated from Email then that case should be assigned to logged in user instead of default case owner that is defined in support setting. 

Jagannathan MJagannathan M
Hi Gupta,

Actually your question is meaningless,because there are multiple users who have logged in when the Case is generated. Try to use Assignment Rules,just assign to User/Queue which is needed.

Thanks.
Narender Singh(Nads)Narender Singh(Nads)

Hi Puja,
In your query there is a small problem, there can be mutiple users logged in at the same time in your org. If you need to assign a case to one of those you need to create a Case Assignment Rule.
https://help.salesforce.com/articleView?id=creating_assignment_rules.htm&type=5
Follow this link for the better understanding of it.

Let me know if it helps.
Thanks.

Puja Gupta 18Puja Gupta 18

Hello 

I can create case assignment rule but i have to assign the cases to logged in user and for assignement i have to use apporach round robin alogrith. In case assignment how can i get the looged in user list?

Narender Singh(Nads)Narender Singh(Nads)
Hey Puja,
Your requirement will require you to write custom apex code (a trigger). This requirement of yours can't be fulfilled using Case assignment rule.
Thanks.
Puja Gupta 18Puja Gupta 18

Hello 

Yes I know i hve to write custom apex code but for every case i have to get logged in user list and have to assign case using round robin algorithm.so i did not know about the how to get logged in users list and assign case one by one. 

Narender Singh(Nads)Narender Singh(Nads)
Hi Puja,
This might get a little complex. But it's doable.
To get this done, you can start by writing a trigger and then use this SQOL query to get a list of active sessions
Select UsersId, UserType, SourceIp, SessionType, SessionSecurityLevel, ParentId, NumSecondsValid, LogoutUrl, LoginType, LoginHistoryId, 
          LastModifiedDate, CreatedDate 
          From AuthSession 
          Where SessionType = 'UI'
Note: You can remove the unnecessary request fields

From this query you will get a list currently active user IDs. 
Now you can do another query to get the names of users using the User ID list.

Now you can write your custom logic for how to assign the case to which user.

Let me know it this helps.
Thanks!
Puja Gupta 18Puja Gupta 18

Hello 

Thanks for your reply and its useful for getting active logged in user lists.  but now i have to apply round robin approach for case asignement .

For example : if case 1: then first user have to assign case

for 2 : 2 user will assign to case if he logged in other wise 3 user will assign. 

if next case will come then again case willa ssign to first loggend in user.

Hari Haran 82Hari Haran 82

hi puja Gupta, 

did you get Any Solutions? In the same scenario, we are stuck  in 4  days