Kevin Baxter
07/21/2023, 5:46 PMconst 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?battk
07/21/2023, 5:50 PMShawn Talbert
07/21/2023, 6:08 PMconst beforeSubmit = (scriptContext) =>
instead of simply function beforeSubmit(scriptContext)
? That's more syntax and symbols so I don't see the benefit?battk
07/21/2023, 6:39 PMec
07/21/2023, 8:08 PMShawn Talbert
07/23/2023, 9:06 PMthis
? Though in my experience I don't know if I've ever seen anyone trying to use this
within an entrypoint function.