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
kingsixkingsix 

Map custom picklist between Accounts and Quote

Hello,

 

I wrote the trigger to mapping the custom field 'Payment_Terms__c' (it's a picklist) between Accounts and Quote, but it show the error info when I save the trigger,

 

trigger test3 on Account (after insert, after update) {
    Map<String, String> SetupFormMap = new Map<String, String>();
    for (Account acc : System.Trigger.new){
        if (acc.Payment_Terms__c != null){
                SetupFormMap.put(acc.ID, acc.Payment_Terms__c);
        }


list<Quote> recordsforupdates = new List <Quote>();

For (Quote aacc :[Select OpportunityId, Payment_Terms__c from Quote where Payment_Terms__c IN : SetupFormMap.keySet()] )
 
{

if (SetupFormMap.containsKey(aacc.Payment_Terms__c)) {
           String actName = SetupFormMap.get(Payment_Terms__c);
            recordsforupdates.add (new recordsforupdates (Id = aacc.Id, Payment_Terms__c = actName));
               }
        }
}
update recordsforupdates;
        }

 

Anyone can help the me? Great Thanks.

sandersensandersen

Your SetupFormMap map has account id as your keyset, but it looks like you're expecting the payment terms as the keys.

 

This line has an error:

 

recordsforupdates.add (new recordsforupdates (Id = aacc.Id, Payment_Terms__c = actName));

 

I think you're trying to create a Quote object here, so it should be 'new quote', not new recordsforupdates.