function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
justin_sfdcjustin_sfdc 

validation help

Hi,

 

I need to fire an error on click of a custom button, which creates a new record. There is an object called Path, and another objects are: Opportunity and Boats. An opportunity can have multiple boats. I need to fire an error message when a New Path custom button is clicked and the condition for this to happen is when a field; which is a number field in opportunity is less than combination of shipment number fields in boats object.

 

Please suggest if there are any other ways to do this as well.

 

Thanks!

 

sushant sussushant sus
if their is masterdetail relation between opportunity and Boats
you can use sum roll up field to calculate total

then normal compare it in validation
justin_sfdcjustin_sfdc

There is a master-detail Relationship between Opportunity and Boats, 

lookup relation between Opportunity and Path.

No relation between Path and Boats

-------------------------------------------------

Field in Opportunity is BoatHours; which is of DataType Number

Field in Boats is Receiving_Hours: which is of DataType Picklist

 

Now, let's say an Opportunity named as Test 1 has 3 boats records, the receiving_Hours field in boats for three records are: 15, 25, 50

Case1: BoatHours in Opportunity = 50

     In this case, when the user clicks on customButton "New Path" in order to create a new Record for Path Object then it should compare Opportunity.BoatHours and the sum of receiving_Hours in boats, which would be if 50 is greater than (15+25+50). In this case, the condition is false so, the error message should not be thrown.

 

Case 2: BoatHours in Opportunity = 100

     In this case, when the user clicks on customButton "New Path" in order to create a new Record for Path Object then it should should do the same comparision, which would be if 100 is greater than (15+25+50). In this case, the condition is true so, the error message should be thrown, and therefore, not let the user create new record in Path Object.

 

Sorry for not being able to elaborate it earlier.


Thanks a lot.