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
fourfourfunfourfourfun 

Set custom field in user profile

Hi,

 

Without the ability to have lookup fields in the User profile or Workflows, I'm looking to try and Apex solution to my problem.

 

I would have a field on the User's profile called:

 

Region

 

I will also have an object which will have a lookup that will contain:

 

A user on the system

A region (which is a lookup field itself)

 

Using that user as the relationship, I want to pull off what Region they are and populate that field on the User profile.

 

Is this something that is relatively easy to achieve?

 

 

sushant sussushant sus
try this

trigger test on custom object(before insert,before update)
{
for(customobject c:trigger.new)
list1.add(c.user__c);
list2.add(c.region_c);
map1.put(c.user__c,c.region__r.name)
}
list<user>u=[select name from user where id in:list1];
for(user u1:u)
{
u1.region__c=map1.get(u1.id);

}

}
Bhawani SharmaBhawani Sharma
Create a trigger on your custom object and update the user record at the same time like
update new User(Id = userId, Region = region);
fourfourfunfourfourfun

Thanks guys, I shall have a play with your suggestions.