The following code goes over all opportunities updated in a transaction and updates their Type field to "Renewal" if the owner's role contains the string "Customer"
list<Opportunity> oppsToUpdate=new list<Opportunity>(); for (Opportunity opp :opps){ if (opp.Owner.UserRole.Name!=null&&opp.Owner.UserRole.Name.contains('Customer')){ opp.Type='Renewal'; oppsToUpdate.add(opp); } } if (!oppsToUpdate.isEmpty()) update oppsToUpdate;
Based on the code above as a reference point, write a piece of code that goes over all opportunities in a transaction, checks whether the Type field is "New Deal" and updates the Amount field to 30,000, but only if it's current value is below 30,000 (i.e. if the amount is 42,000, the system will not update the amount, but if the amount is 10,000 it will be updated to 30,000). In addition, if the amount is not a multiple of 100, the system will update the amount to the nearest 100 (i.e. 40,210 will be updated to 40,200).
The following code goes over all opportunities updated in a transaction and updates their Type field to "Renewal" if the owner's role contains the string "Customer". list<Opportunity> oppsToUpdate=new list<Opportunity>(); for (Opportunity opp :opps){ if (opp.Owner.UserRole.Name!=null&&opp.Owner.UserRole.Name.contains('Customer')){ opp.Type='Renewal'; oppsToUpdate.add(opp); } } if (!oppsToUpdate.isEmpty()) update oppsToUpdate;
Based on the code above as a reference point, write a piece of code that goes over all opportunities in a transaction, checks whether the Type field is "New Deal" and updates the Amount field to 30,000, but only if it's current value is below 30,000 (i.e. if the amount is 42,000, the system will not update the amount, but if the amount is 10,000 it will be updated to 30,000). In addition, if the amount is not a multiple of 100, the system will update the amount to the nearest 100 (i.e. 40,210 will be updated to 40,200).
list<Opportunity> oppsToUpdate=new list<Opportunity>();
for (Opportunity opp :opps){
if (opp.Owner.UserRole.Name!=null&&opp.Owner.UserRole.Name.contains('Customer')){
opp.Type='Renewal';
oppsToUpdate.add(opp);
}
}
if (!oppsToUpdate.isEmpty())
update oppsToUpdate;
Based on the code above as a reference point, write a piece of code that goes over all
opportunities in a transaction, checks whether the Type field is "New Deal" and updates the
Amount field to 30,000, but only if it's current value is below 30,000 (i.e. if the amount is 42,000,
the system will not update the amount, but if the amount is 10,000 it will be updated to 30,000).
In addition, if the amount is not a multiple of 100, the system will update the amount to the
nearest 100 (i.e. 40,210 will be updated to 40,200).
Thanks,
SS
Hope you are doing well..!!
Can you please update
if (opp.Owner.UserRole.Name!=null&&opp.Owner.UserRole.Name.contains('Customer')){
to
if (opp.Owner.Name!=null&&opp.Owner.Name.contains('Customer')){
Let me know If it works.
Thanks,
Foram Rana
The following code goes over all opportunities updated in a transaction and updates their Type field to "Renewal" if the owner's role contains the string "Customer".
list<Opportunity> oppsToUpdate=new list<Opportunity>();
for (Opportunity opp :opps){
if (opp.Owner.UserRole.Name!=null&&opp.Owner.UserRole.Name.contains('Customer')){
opp.Type='Renewal';
oppsToUpdate.add(opp);
}
}
if (!oppsToUpdate.isEmpty())
update oppsToUpdate;
Based on the code above as a reference point, write a piece of code that goes over all
opportunities in a transaction, checks whether the Type field is "New Deal" and updates the
Amount field to 30,000, but only if it's current value is below 30,000 (i.e. if the amount is 42,000,
the system will not update the amount, but if the amount is 10,000 it will be updated to 30,000).
In addition, if the amount is not a multiple of 100, the system will update the amount to the
nearest 100 (i.e. 40,210 will be updated to 40,200).
Thanks,
SS