You need to sign in to do that
Don't have an account?
Query for auto populating the Field
Hi Pros,
i have been trying to auto Populate a field from another field value based on Ajax Triggers, but i get error.
here is the scenario:
Under accounts standard Object i have a custom field called as Control Location.
Under User standard object i have a custom field also called as Control Location.
Account and Users are connected based on a lookup of sales Representative (renamed Account Owner field).
i would like to auto populate the account's Control Location based on the value of Control Location in the user Object.
here is my Query:
trigger populatecontrolLocation on Account(before insert, before update)
{
// for each account, create a new trigger
for(Account a : Trigger.new)
{
// Create a list of user records from a SOQL query
List <User> accusr = [SELECT Control_Location__c FROM User WHERE id = : a.Ownerid];
// for each account user
a.Control_Location__c = accusr.get(0);
}
}
and here is the error i receive:
error : Illegal assignment from SOBJECT:User to String
any suggestions would be more than welcome.
best regards,
Mojtaba
Hi,
Try this,
a.Control_Location__c = accusr.get(0).Control_Location__c;
Regards,
Imran
Or:
a.Control_Location__c = accusr[0].Location;