• Lance Brown
  • NEWBIE
  • 5 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 5
    Replies
WHat did I do wrong?  I'm unable to dataload any changes.


trigger LOC_on_IP on SVMXC__Installed_Product__c (before insert, before update) {

    List<SVMXC__Installed_Product__c> locationToUpdate = new List<SVMXC__Installed_Product__c>();

    for (SVMXC__Installed_Product__c ip : Trigger.new)
    {    
      if (ip.SVMXC__Company__c != NULL)
      {
          // Find the Loaction for the current Acct
          List<SVMXC__Site__c> loc = [select Loc_ID__c from SVMXC__Site__c
                             where SVMXC__Account__c = :ip.SVMXC__Company__c limit 1];     
               
          // if you found one
          if (loc.size() > 0)
          {   
              //assign the Location to the Accounts Location
              ip.SVMXC__Site__c  = loc[0].Loc_ID__c;
         
              locationToUpdate.add(ip);
         
          }
       }
    }
}
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
        }
    }
}
We cover every State in the US, and have 100+ salespeople with a very complex territory.  This Salesforce site discusses what we should do, just not who the trigger should look or a sample.(http://help.salesforce.com/apex/HTViewSolution?id=000001140&language=en_US)   I've created the Custome Object and uploaded all of the Zip Cades and linked with the Salesforce User.  I just need help writing the trigger and class.  Any help :)
WHat did I do wrong?  I'm unable to dataload any changes.


trigger LOC_on_IP on SVMXC__Installed_Product__c (before insert, before update) {

    List<SVMXC__Installed_Product__c> locationToUpdate = new List<SVMXC__Installed_Product__c>();

    for (SVMXC__Installed_Product__c ip : Trigger.new)
    {    
      if (ip.SVMXC__Company__c != NULL)
      {
          // Find the Loaction for the current Acct
          List<SVMXC__Site__c> loc = [select Loc_ID__c from SVMXC__Site__c
                             where SVMXC__Account__c = :ip.SVMXC__Company__c limit 1];     
               
          // if you found one
          if (loc.size() > 0)
          {   
              //assign the Location to the Accounts Location
              ip.SVMXC__Site__c  = loc[0].Loc_ID__c;
         
              locationToUpdate.add(ip);
         
          }
       }
    }
}
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
        }
    }
}
We cover every State in the US, and have 100+ salespeople with a very complex territory.  This Salesforce site discusses what we should do, just not who the trigger should look or a sample.(http://help.salesforce.com/apex/HTViewSolution?id=000001140&language=en_US)   I've created the Custome Object and uploaded all of the Zip Cades and linked with the Salesforce User.  I just need help writing the trigger and class.  Any help :)