CONTEXT: For each of the customer at our company, we want to populate a "revenue target" field which depends on other fields the end-user is inputting (e.g. if the customer is a national chain, which services we are providing to them).
For the more simple calculations, I have been using a workflow and set field value action (before record submit) and using CASE WHEN statements as a formula. For example,
Revenue Target=CASE WHEN {custrecord52} = 'National Chain' THEN 7500
WHEN {custrecord52} = 'Regional Chain' THEN 5750
WHEN {custrecord52} = 'Independent' THEN 4000
ELSE 0
END
QUESTIONS: I have three main questions.
- How can I do something similar for client triggers like before user submit (which according to this documentation requires a JavaScript formula:
).
- Is there a way I can use a function in the formula section? (Either using client triggers/JS or server triggers/SQL). Essentially, I need to evaluate multiple parameters sequentially and adjust the predicted revenue (e.g. set a base revenue to N based on subcategory, add to the value conditionally (N+X), then multiply the new/current price conditionally (Y * (N+X)) so I would like to store and update a variable before setting the final revenue target). The N,X, and Y are also subject to change in the future as we tweak the formula. How could I write the function and store the result in the field? (e.g. do I define a function and call it? I'm confused about the logistics and if this is possible)
- Would a SuiteScript/Workflow Action Script work better? I have programming knowledge and the actual if-else statements are very straightforward for now (I can write up the pseudocode if that helps).
Sorry for the long explanation. I hope my question/use-case is clear and I'd appreciate any advice or solutions. I am fairly new to NetSuite in general so I am not sure which methods would work and/or if there is an easier solution that I am glossing over. Thanks in advance!