You need to sign in to do that
Don't have an account?
EvertonSzekeres
Bring all assets
Hi,
I am trying send and email that will bring me all the assets from account.
In this trigger I only get the last asset created and not all the list.
Thanks !
I am trying send and email that will bring me all the assets from account.
Set <id> ids = new Set <id> (); for (Account acc: trigger.new) { ids.add(acc.id); } for (Asset ast: [SELECT Id, Name, Quantity FROM Asset WHERE Quantity>0 AND accountid IN: ids]){ for(Account acc : trigger.new){ if(acc.separador__c == 'pesquisa'){ Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); String[] toAddresses = new String[]{}; toAddresses.add(acc.PersonEmail); toAddresses.add(acc.Email_alternativo__c); mail.setToAddresses(toAddresses); mail.setreplyto('naoresponda@cp7.com.br'); mail.setSubject('Pesquisa'); mail.setHtmlBody('Olá, '+acc.FirstName+''+acc.LastName+'<p>'+ast.Name+'</p>');
In this trigger I only get the last asset created and not all the list.
Thanks !
Its not complete code. Can you paste your complete code
Take the referance from this code. May be It will help you to solve your issue.
Map<Id,Account> accountMap = new Map<Id,Map>([Select Id,NAme,(Select Id,Name from Assets where Quantity>0) from Account and Id in : Trigger.New]);
for(Account Ac : Trigger.New){
Email Code....................
//
Onkar
It's almost perfect !
But in my email I am receiving a null asset:
Olá, Xxx Xxx
null, "AMPLIAÇÃO", "FOTO 20X30CM", "DVD", "AR - SUPER VIP"
Why I am receiving null?
My code:
if(accountMap.get(Ac.Id).Assets.size() > 0){
for(Asset obj : accountMap.get(Ac.Id).Assets){
if(obj.Name != null){
AssetName = AssetName + ', ' + +'"'+obj.Name+'"';
}
}