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

How to pass user id for below field ?

For a Case record, if a specified profile user edits the record and save. The user name should populate on  Case field. But whenm i add the condition it was empty. Where it is wrong ?

trigger UpdateCase on Case(before insert,before update) {

set<id> cset = new set<id>();
//Id profileUser = UserInfo.getProfileId();
//profile p = [select id,name from profile where name = 'Operations'];

List<Case> CaseList = [select id,Assigned_To__c from case where id in:cset];

List<User> UserList = [select id,,Lastname,name from User];

for(User u :UserList ){
if( == '0098467tXEr6767'){
Cs.Assigned_To__c =;
Cs.UserName__c =;
Mark TroupeMark Troupe
Your UserList query is returing ALL users, not just the user editing the record.

List<User> UserList = [select id,,Lastname,name from User where id =: UserInfo.getUserId limit 1];
This will only return 1 User so you dont need to loop through the list