• Gurjit Singh 22
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 6
    Replies
It may sound little weird but can someone please explain how the below loop manages to get the lowest value
Decimal LowestPrice;
//for loop to find the smallest value
 for(Integer i = 0;i<leadingPrice.size();i++){
//no idea how the below line is getting the lowest value
if(LowestPrice == null || leadingPrice.get(i) < LowestPrice){
lowestprice = leadingPrice.get(i);
 }
LeadingPrice is a List of Decimals and above loop is assigning the lowest value to the variable lowestprice, can someone please explain the working of above loop Thank you in advance.
As per the below code, this meant to update the first and last name only if I update a new lead but it is updating the first and last name of new lead as well Can someone please suggest. Thank you!

trigger HelloWorld on Lead (before update) {
for(Lead l : Trigger.new){
l.FirstName = 'Hello';
l.LastName = 'World';

}
 
As per the below code, this meant to update the first and last name only if I update a new lead but it is updating the first and last name of new lead as well Can someone please suggest. Thank you!

trigger HelloWorld on Lead (before update) {
for(Lead l : Trigger.new){
l.FirstName = 'Hello';
l.LastName = 'World';

}
 
Hi All,

I am new to Salesforce and I just wrote my first Hello World Trigger on Lead object as below.

trigger HelloWorld on Lead (before update) {
    for (Lead l: Trigger.new) {
        l.FirstName='Hello';
        l.lastName='World';
    }

Guess what, this thing is running even when I create new Lead and setting the first and last names to hello world. What am I doing wrong?

- Amar