You need to sign in to do that
Don't have an account?
Lance Brown
Trigger look up from text field both on Account page
Trying to write a trigger to copy a custom zip code field on the account page to a lookup of a custom object.
the custom zip code feild is Equipment_Zip_Postal_Code__c
The lookup field also on the account page is TZ__c
The Custom Object API name is TZDatabase__c
with a field name of Name that need to be copied over
So far I'm getting a Invalid bind expression type of Schema.SObjectField for colimn of type String.
Any help would be GREAT
trigger TZ on Account (after update) {
String AccountId;
String TextFieldValue;
for(Account acc : Trigger.New)
{
AccountId = acc.id;
TextFieldValue = acc.Equipment_Zip_Postal_Code__c;
}
list<TZDatabase__c> TZDatabaseList = new list<TZDatabase__c>();
TZDatabaseList = [SELECT id, Name FROM TZDatabase__c WHERE Name =: account.Equipment_Zip_Postal_Code__c ];
if(TZDatabaseList.size() > 0)
{
for(TZDatabase__c acc : TZDatabaseList)
{
account.TZ__c = Account.Equipment_Zip_Postal_Code__c;
}
try{
update TZDatabaseList;
}
catch(Exception ex)
{
//add error message
}
}
}
the custom zip code feild is Equipment_Zip_Postal_Code__c
The lookup field also on the account page is TZ__c
The Custom Object API name is TZDatabase__c
with a field name of Name that need to be copied over
So far I'm getting a Invalid bind expression type of Schema.SObjectField for colimn of type String.
Any help would be GREAT
trigger TZ on Account (after update) {
String AccountId;
String TextFieldValue;
for(Account acc : Trigger.New)
{
AccountId = acc.id;
TextFieldValue = acc.Equipment_Zip_Postal_Code__c;
}
list<TZDatabase__c> TZDatabaseList = new list<TZDatabase__c>();
TZDatabaseList = [SELECT id, Name FROM TZDatabase__c WHERE Name =: account.Equipment_Zip_Postal_Code__c ];
if(TZDatabaseList.size() > 0)
{
for(TZDatabase__c acc : TZDatabaseList)
{
account.TZ__c = Account.Equipment_Zip_Postal_Code__c;
}
try{
update TZDatabaseList;
}
catch(Exception ex)
{
//add error message
}
}
}
instead of
By the way there are lot many issues with your code
http://www.sfdc99.com/2013/11/17/what-are-governor-limits/
My site!