+ Start a Discussion
mac adminmac admin 

Role as madatory

Hi all,
Can we make the Role field as madetory, While creating user. Actually it shows as madatory but it is not madatory. Can anyhelp how we can make Role field as mandatory other than using validation rule(If I'm wrong correct me.)

Thanks in advance,

Regrads,
mac.
Prateek BhattPrateek Bhatt
Hi Mac,

Standard fields of user object can't be modified in page layout. We can't make role as required from page layout. The alternative way to do this either validation rule or trigger. You can create a trigger on user object to validate the role.
 
trigger validateRole on user (before insert, before update) {
	if(user u : Trigger.New) {
		if(u.UserRoleId == '') {
			u.addError('Role is required');
		}
	}
}

Thanks
Arvind KumarArvind Kumar
Hi Mac,

You can make validation rule. Through valiadtion rule can make required Role on User page layout.

Use this formula in validation rule.
ISBLANK( UserRole.Name )

Display Error: Role is required

Mark as best answer, if it solves your problem.

Thanks,

Arvind Kumar