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
kk1985kk1985 

Restrict users based on license type

I have a scenario where a case should only be assigned to Users with User License Type 'Salesforce'. If it is assigned to anyone else with a different License Type, the Case should throw an error message when saved. I tried to use Validation Rule, but i'm unable to get this done. Any advise will be of great help. Thank you!
Best Answer chosen by kk1985
Prateek Singh SengarPrateek Singh Sengar
Try this.
NOT(ISPICKVAL( Owner:User.UserType , 'Standard') )

All Answers

Prateek Singh SengarPrateek Singh Sengar
Hi Krishna,
Not sure about your use case, but what other license type do you have that can access Case object?

I believe if you should write a validation on caseowner to check for standard user type: 

The validtion on the caseowner field will look like

 Owner:User.UserType  <> 'Standard'

Now standard user type have the following license type
Salesforce
Salesforce platform 
Salesforce platform one

Out of the above three only salesforce license user can have access to case object. Therefore by checking for standard user type you should be fullfilling your user case.

Hope it makes sense.
 
kk1985kk1985
Hi Prateek,

Thanks for your response. Company Communities and Salesforce License types that we have in the org.
Prateek Singh SengarPrateek Singh Sengar
In that case my above suggestion would work as Company communities come under usertype "PowerPartner". Please try it and let me know if it worked for you.
kk1985kk1985
May be im doing something wrong. I'm getting this error message.. "Error: Field UserType is a picklist field. Picklist fields are only supported in certain functions. "  Please help
Prateek Singh SengarPrateek Singh Sengar
Try this.
NOT(ISPICKVAL( Owner:User.UserType , 'Standard') )
This was selected as the best answer
kk1985kk1985
Prateek, I tried NOT(ISPICKVAL( Owner:User.UserType , 'Standard') ) but im able to assign the case to both Salesforce User type and Company Community User types. I removed NOT and i'm able to assign case to Company Community but not to Salesforce User type, which is the reverse of what i need. Would you be able to provide further advise ?
Prateek Singh SengarPrateek Singh Sengar
Hi Krishna,
I tried this validation rule and it worked. Can you double check if the user you were trying to assign the case was indeed a community user.

Community user error
kk1985kk1985
Prateek, I checked and its Company Communities User type. But for some reason its not working.
Prateek Singh SengarPrateek Singh Sengar
Can you share screenshot of user record and its profile. It will help us understand where things are going wrong.
kk1985kk1985
Hi Prateek, there was another validation rule that was having conflict. I disabled it and this one worked. Thank you so much!
Prateek Singh SengarPrateek Singh Sengar
Thats great i was scratching my head and wondering what could be going wrong since it was working in my org. :)