You need to sign in to do that
Don't have an account?
Suneel B 9
I am trying ti change ownership field to public when type is prospect in the account field using trigger, below is my program can you please help me out:
Hai all,
I am trying ti change ownership field to public when type is prospect in the account fiels using trigger, below is my program can you please help me out:
trigger oppinsert on Account (After insert)
{
set<id> accid = new set<id>();
List<Account> acc = Trigger.new;
for(Account accset1:acc)
{
if( accset1.Type == 'Prospect'){
// accset1.Ownership = 'Public';
accset1.Ownership.addError('Please select');
}
}
for(Account accset:acc)
{
accid.add(accset.id);
}
List<Account> acclst = [Select name,id from Account where id In:accid];
List <Opportunity> opp = new List<Opportunity>();
for (Account ac:acclst)
{
Opportunity o =new Opportunity();
o.Name = ac.Name;
o.CloseDate = system.today();
o.StageName = 'prospecting';
o.Accountid = ac.id;
opp.add(o);
}
insert opp;
}
I am trying ti change ownership field to public when type is prospect in the account fiels using trigger, below is my program can you please help me out:
trigger oppinsert on Account (After insert)
{
set<id> accid = new set<id>();
List<Account> acc = Trigger.new;
for(Account accset1:acc)
{
if( accset1.Type == 'Prospect'){
// accset1.Ownership = 'Public';
accset1.Ownership.addError('Please select');
}
}
for(Account accset:acc)
{
accid.add(accset.id);
}
List<Account> acclst = [Select name,id from Account where id In:accid];
List <Opportunity> opp = new List<Opportunity>();
for (Account ac:acclst)
{
Opportunity o =new Opportunity();
o.Name = ac.Name;
o.CloseDate = system.today();
o.StageName = 'prospecting';
o.Accountid = ac.id;
opp.add(o);
}
insert opp;
}
acc.Ownership won't work as that is the format for a standard field - instead it would be acc.Ownership__c or similar.
What specific problems are you encountering?
I created a new trigger.
trigger acc1 on Account (before insert, before update) {
for(Account a:Trigger.new)
{
if (a.Type =='Prospect')
{
a.Ownership = 'Public';
}
else{
a.Ownership = null;
}
}
}
This is it..
Anyways thanks .