You need to sign in to do that
Don't have an account?
sai krishna 267
I have a question...I have account record in that record there is a three opportunities r there. in Account field there is a one custom field its name is all_oppnames__c in that field that all opportunities names will be displayed comma(,) symbol.by
I have a question...I have account record in that record there is a three opportunities r there. in Account field there is a one custom field its name is all_oppnames__c in that field that all opportunities names will be displayed comma(,) symbol.by using triggers can any bodygive the code for that......
I'm pretty proud of that to be fair considering you have literally just asked a forum to do you work for you, I hope you can beat it into a good working shape!
change line 26 to
and then you'll have to cleverly strip the first leading coma off th result (there's a String method for that)
updatedAccounts.put(thisId, new Account(Id = thisId , all_oppnames__c = ' ' );
Error: Compile Error: Missing ')' at ';' at line 16 column 84
The clue is in:
Trust me, it's right there!
this error can u clear me
this error can u clear me @sriawk
I have neglected to add the "id" field to the parameter in the Set add method.
The set is defined as being a set of Id values... on line 2, but then on line 6 I am trying to add an Account object. This needs adjusting so line 6 is actually adding the Id of the Account to the instead! Simple enough :)
I should warn you, as per the cavaet in my original answer, I just hand typed that into the comment box, so it may be riddled with little complier errors, which you may have to debug.
SELECT Id, Name FROM Account WHERE Account =:parentIds
^
ERROR at Row:1:Column:36
No such column 'Account' on entity 'Account'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names. at line 10 column 32
Trigger saiTrigger on Opportunity (after insert, after update, after delete, after undelete) {
Set<Id> parentIds = new Set<Id>();
// get all the accounts then
for (Opportunity thisOpp : Trigger.new) {
parentIds.add(thisOpp.AccountId);
}
// load all the opps for those accounts
List<Opportunity> allOpps = [SELECT Id, Name FROM Account WHERE Account =:parentIds];
Map<Id, Account> updatedAccounts = new Map<Id, Account>();
// go through those accounts and blank the field and associate them with their id
for(Id thisId : parentIds) {
updatedAccounts.put(thisId, new Account(Id = thisId, all_oppnames__c = ''));
}
// I'm gunna use an extra list here as I'm too tipsy to think about scope in maps etc...
List<Account> resultAccounts = new List<Account>();
// now concat all the opp names back into their account
for(Opportunity thisOpp : allOpps) {
Account itsAccount = updatedAccounts.get(thisOpp.Account);
itsAccount.all_oppnames__c = itsAccount.all_oppnames__c + ', ' + thisOpp.name;
resultAccounts.add(itsAccount);
}
update resultAccounts;
}
this error clear please if u dont mine@sriawk uk