Skip to main content
added 1363 characters in body
Source Link
Alex
  • 33
  • 4

I'm trying to get a code to work that will set map an opportunity owner to the account owner but I'm getting failures for two lines. Any ideas?

Broken lines start with a "****"

trigger SetOppOwnerToAcctOwner on Opportunity (before Insert){

    Set<ID> acctIDs = New Set<ID>();
    Map<ID,ID> accToOwner = New Map<ID,ID>();

    for(Opportunity opp : trigger.new){

        acctIDs.add(opp.accountID);

    }

    for(Account a : [Select OwnerID From Account Where ID IN :acctIDs])
****       accToOwner.put(a.id,a.ownerID);


    for(Opportunity opp : trigger.new){
        if(accToOwner.containsKey(opp.AccountID))
****           opp.OwnerID = accToOwner.get(opp.AccountID);
    }

}

I'm trying to get a code to work that will set map an opportunity owner to the account owner but I'm getting failures for two lines. Any ideas?

Broken lines start with a "****"

trigger SetOppOwnerToAcctOwner on Opportunity (before Insert){

    Set<ID> acctIDs = New Set<ID>();
    Map<ID,ID> accToOwner = New Map<ID,ID>();

    for(Opportunity opp : trigger.new){

        acctIDs.add(opp.accountID);

    }

    for(Account a : [Select OwnerID From Account Where ID IN :acctIDs])
****       accToOwner.put(a.id,a.ownerID);


    for(Opportunity opp : trigger.new){
        if(accToOwner.containsKey(opp.AccountID))
****           opp.OwnerID = accToOwner.get(opp.AccountID);
    }

}

I'm trying to get a code to work that will set map an opportunity owner to the account owner but I'm getting failures for two lines. Any ideas?

Broken lines start with a "****"

trigger SetOppOwnerToAcctOwner on Opportunity (before Insert){

    Set<ID> acctIDs = New Set<ID>();
    Map<ID,ID> accToOwner = New Map<ID,ID>();

    for(Opportunity opp : trigger.new){

        acctIDs.add(opp.accountID);

    }

    for(Account a : [Select OwnerID From Account Where ID IN :acctIDs])
****       accToOwner.put(a.id,a.ownerID);


    for(Opportunity opp : trigger.new){
        if(accToOwner.containsKey(opp.AccountID))
****           opp.OwnerID = accToOwner.get(opp.AccountID);
    }

}
added 78 characters in body
Source Link
Keith C
  • 137.3k
  • 29
  • 218
  • 458

I'm trying to get a code to work that will set map an opportunity owner to the account owner but I'm getting failures for two lines. Any ideas?

Broken lines start with a "****"

trigger SetOppOwnerToAcctOwner on Opportunity (before Insert){

trigger SetOppOwnerToAcctOwner on Opportunity (before Insert){

    Set<ID> acctIDs = New Set<ID>();
    Map<ID,ID> accToOwner = New Map<ID,ID>();

    for(Opportunity opp : trigger.new){

        acctIDs.add(opp.accountID);

    }

    for(Account a : [Select OwnerID From Account Where ID IN :acctIDs])

**** accToOwner.put(a.id,a.ownerID);

****       accToOwner.put(a.id,a.ownerID);


    for(Opportunity opp : trigger.new){
        if(accToOwner.containsKey(opp.AccountID))
****           opp.OwnerID = accToOwner.get(opp.AccountID);
    }

}

**** opp.OwnerID = accToOwner.get(opp.AccountID); }

}

I'm trying to get a code to work that will set map an opportunity owner to the account owner but I'm getting failures for two lines. Any ideas?

Broken lines start with a "****"

trigger SetOppOwnerToAcctOwner on Opportunity (before Insert){

Set<ID> acctIDs = New Set<ID>();
Map<ID,ID> accToOwner = New Map<ID,ID>();

for(Opportunity opp : trigger.new){

    acctIDs.add(opp.accountID);

}

for(Account a : [Select OwnerID From Account Where ID IN :acctIDs])

**** accToOwner.put(a.id,a.ownerID);

for(Opportunity opp : trigger.new){
    if(accToOwner.containsKey(opp.AccountID))

**** opp.OwnerID = accToOwner.get(opp.AccountID); }

}

I'm trying to get a code to work that will set map an opportunity owner to the account owner but I'm getting failures for two lines. Any ideas?

Broken lines start with a "****"

trigger SetOppOwnerToAcctOwner on Opportunity (before Insert){

    Set<ID> acctIDs = New Set<ID>();
    Map<ID,ID> accToOwner = New Map<ID,ID>();

    for(Opportunity opp : trigger.new){

        acctIDs.add(opp.accountID);

    }

    for(Account a : [Select OwnerID From Account Where ID IN :acctIDs])
****       accToOwner.put(a.id,a.ownerID);


    for(Opportunity opp : trigger.new){
        if(accToOwner.containsKey(opp.AccountID))
****           opp.OwnerID = accToOwner.get(opp.AccountID);
    }

}
Source Link
Alex
  • 33
  • 4

Lack of Apex code Coverage

I'm trying to get a code to work that will set map an opportunity owner to the account owner but I'm getting failures for two lines. Any ideas?

Broken lines start with a "****"

trigger SetOppOwnerToAcctOwner on Opportunity (before Insert){

Set<ID> acctIDs = New Set<ID>();
Map<ID,ID> accToOwner = New Map<ID,ID>();

for(Opportunity opp : trigger.new){

    acctIDs.add(opp.accountID);

}

for(Account a : [Select OwnerID From Account Where ID IN :acctIDs])

**** accToOwner.put(a.id,a.ownerID);

for(Opportunity opp : trigger.new){
    if(accToOwner.containsKey(opp.AccountID))

**** opp.OwnerID = accToOwner.get(opp.AccountID); }

}