Trying to build a formula for a WF to update a bod...
# general
m
Trying to build a formula for a WF to update a body field from line level with a hierarchical approach... I E. If you have 4 lines and the value for each is 1,2,3,4.. The body field based on the value should populate so for example if values on all lines is 1 then populate 1 etc.. however let's say 3 of the lines is 1 and 4th line is 2 then populate 2 on the body field as it's greater and higher in the hierarchy etc etc.. hoping this makes sense
r
To achieve this in a NetSuite workflow, you can use a
Before Record Submit
action and employ either a custom script or a formula that iterates through the line items to find the highest value. If scripting is an option, SuiteScript could be used to loop through line items to find and set the highest value on the body field. In a formula-only approach, you might need to use a series of
CASE
statements or a custom formula field that calculates the maximum line value, which you could then source to the body field. This can get complex if you have many line items and might not be as straightforward as a scripted solution. Here’s a simplified pseudo-formula for illustration:
Copy code
CASE 
  WHEN {item1} > {item2} AND {item1} > {item3} AND {item1} > {item4} THEN {item1}
  WHEN {item2} > {item3} AND {item2} > {item4} THEN {item2}
  WHEN {item3} > {item4} THEN {item3}
  ELSE {item4}
END
This formula checks which line item has the highest value and then populates the body field with that value. Note that you’ll need to replace
{item1}, {item2},...
, with your actual line item field references. If you have more than a few lines, or if the lines can change, a scripted approach would be more dynamic and maintainable.
🤖 1
y
It's very hard to handle by workflow. It's very simple and easy to achieve this functionality by suitescript.
💯 1