Hi all, I need some direction to develop a specifi...
# suitescript
j
Hi all, I need some direction to develop a specific wish we have. We have a workflow running on the Sales Order that initiates an approval flow. In the workflow is a specific Submit for Approval button (custom added via Workflow). If that button is pressed, I want to do a validation if there are files attached on the Sales Order. If so, the Sales Order should go into the approval flow (other state) If not the user should see a message that he/she should add an attachment. I have a working client script that can detect if any files are attached but this works on the Submit/Save button (saveRecord). How should I setup my scripts so that the validation will go off when clicking the: Submit for Approval (custom button)?
b
although i believe all workflow action scripts are maintenance nightmares
may not be quite the same since these tend to end up being server scripts
in general, there is only suffering trying to mix scripts and worflows
j
Ok, the wish we have does not sound very uncommon to me. Is it possible to catch the click of the custom button and do the validation within client script?
b
the exact thing is uncommon
suitescript doesnt offer a direct connection to workflow buttons outside of workflow actions
you can use javascript to add an event listener to the workflow button, but that has all the maintenance and testing requirements of DOM manipulation
j
Ok, is there more information on those maintenance and testing requirements?
b
you are doing something that netsuite says is unsupported
expect to test your script every release
if its critical, expect to test it every hot fix
j
Aha, thanks @battk
f
one more thing. putting the verifications on the client side is not a good option (if you put them only in client side), so I'd suggest you to perform the verifications server side and add a custom hidden field (custpage_...something)... and finally swith to scripting to have full control of the process. a user event script in beforeLoad would allow you to: • check if the SO is in the state that need an approval • add a message if the order doesn't meet the requirements to be approved • add a button for the approval (disabled if you can't approve the SO)