```const beforeSubmit = (scriptContext) => { ...
# suitescript
k
Copy code
const beforeSubmit = (scriptContext) => {

    try{
        var recordObj = scriptContext.newRecord

        var productionHours = recordObj.getValue({
            fieldId: 'custrecord_lf_production_hours_erp'
        })

        var fullfilled = recordObj.getValue({
            fieldId: 'custrecord_lf_fulfilled_erp'
        })

        var futureShip = recordObj.getValue({
            fieldId: 'custrecord_lf_futureship_erp'
        })

        var results = Math.round((fullfilled + futureShip) / productionHours)




        var answer;

        if(results  <= 250 ){
            answer = "Payout: $30/per month"
            return;
        }else if(results  >= 251 && results <= 275){
            answer = "Payout: $40/per month"
            return;
        }else if(results >= 276 &&  results <= 300){
            answer = "Payout: $50/per month"
            return;
        }else if(results >= 301 && results <= 325){
            answer = "Payout: $60/per month"
            return;
        }else if(results >= 326 && results <= 350){
            answer = "Paytout: 70/per month"
            return;
        }





        recordObj.setValue({
            fieldId: 'custrecord_lf_custom_result_ns',
            value: answer
        })
        recordObj.setValue({
            fieldId: 'custrecord_lf_results_erp',
            value: results
        })
    }catch (e){
        log.debug("Error", e)
    }




}
[1:22 PM] I have a field that is free-form-text and I cannot get it to populate answer. Any ideas?
b
s
I'm curious why people are defining entryponts like
const beforeSubmit = (scriptContext) =>
instead of simply
function beforeSubmit(scriptContext)
? That's more syntax and symbols so I don't see the benefit?
👍 1
b
its the default template for the webstorm plugin
🤮 1
e
And vs code
s
unless they are intentionally trying to coax people to lexical
this
? Though in my experience I don't know if I've ever seen anyone trying to use
this
within an entrypoint function.