You need to sign in to do that
Don't have an account?
CBN
How to Execute in anonymous window for below code
Hi All,
How to excute below code in Anonymous window
Kindly Support and suggest
Thanks
How to excute below code in Anonymous window
public class UserUpdate { public static void updateUser(List<ID> ids){ Id taskId = 'aAY2h0000004CANGA2'; delete [SELECT Id from PermissionSetAssignment where AssigneeId=:userId and PermissionSet.ProfileId=null]; delete [Select Id from GroupMember where UserOrGroupID=:userId]; delete [SELECT Id FROM UserPackageLicense where UserId=:userId]; Profile prf = [select id from Profile where Name='ServiceDesk Client']; User usr = [select IsActive,UserRoleId,ProfileId,Title,ManagerId from User where id=:userId]; usr.UserRoleId = null; usr.ProfileId = prf.id; usr.Title = null; usr.ManagerId = null; usr.IsActive = false; update usr; } }
Kindly Support and suggest
Thanks
We can execute below code in anonymous window like below, But, i have below questions on the code,
1. From where are we getting the value for variable 'userId' ?
2. I could see the variable 'ids' is not used anywhere
Thanks,
Govindaraj.S
- You have to pass List of ids as a parameter of the method.
- A static method is called by class name so you need to execute the above code from the execute anonymous-
List<Id> ids = new List<Id>();
ids.add(id); //push ids on the list
UserUpdate.updateUser(ids);
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks,
Ajay Dubedi