You need to sign in to do that
Don't have an account?
nisha c o
CreatedBy ID field of User object
Hi,
i am writing a formula field on User object which access CreatedBy ID field. but does not seem that i can access that field. it does not appear when i click on Insert Field button. does any one know how to access that field or any other work around?
thanks in advance!
Hi Nisha,
Firstly create this field on User Object : Created_By_Id__c [Text(18)]
After that paste this one code for User Object :
trigger updateCreatedById on User (before insert, before update) {
if (Trigger.isBefore) {
if (Trigger.isInsert) {
for(User u : trigger.New){
u.Created_By_Id__c = UserInfo.getUserId();
}
}
}
}
Now test it by creating new User.
All Answers
Hi Nisha,
Write a trigger on insert of User Object and Create a Text field on User Object. After that you can access that field as per your requirement.
Hi Nisha,
Firstly create this field on User Object : Created_By_Id__c [Text(18)]
After that paste this one code for User Object :
trigger updateCreatedById on User (before insert, before update) {
if (Trigger.isBefore) {
if (Trigger.isInsert) {
for(User u : trigger.New){
u.Created_By_Id__c = UserInfo.getUserId();
}
}
}
}
Now test it by creating new User.
thank you so much!! it worked! :)