I would like that a certain script is only trigger...
# suitescript
r
I would like that a certain script is only trigger when (scriptContext.type === scriptContext.UserEventType.APPROVE). When is the approve context triggered? Because in my approval workflow, in the approval state where the approval status is being set to "Approve" is not triggered, I am getting instead scriptContext.UserEventType.EDIT. Otherwise I guess the solution might be that I use a custom field to create my own correct context, but just double checking in case someone experienced this before.
c
Hi @Roc127, The scriptContext.UserEventType will be in EDIT and in your condition you will have to add a comparison between your scriptContext.oldRecord status (pending approval) and your scriptContext.newRecord's one (pending fulfillment)
b
aprove context is triggered when the approve button is set
setting the status field normally is an edit
r
But how does NetSuite knows which one is the Approve button? As specified here Execute User Event Script when Approve Button from Sales Order is Clicked https://suiteanswers.custhelp.com/app/answers/detail/a_id/32560/loc/en_US As at the end is just a custom button:
Is there a "native" approve button that triggers the approve context?
Due to the nature of my WF, the comparison does not fit in this use case, as you have several steps to get to approval and then pending fulfillment or billing. I am trying to signal this button clicked from the workflow to my script, but I am getting some race condition issues that I am trying to fix.
b
the approve event is only triggered for the actual approve button
naming a button approve and having it set the status checkbox is an edit
r
And which one is the actual approve button? I am honestly confused as I see a few solutions from NetSuite when it comes to approvals. Here is a bit of an overview: Marty Zigman on "Sort Out NetSuite’s Options for Approval Workflows" https://blog.prolecto.com/2019/05/13/sort-out-netsuites-options-for-approval-workflows/
Is there a way in my custom workflow that I can add the "native" approve button? So the context Approve would get triggered
I have seen this article - NetSuite Applications Suite - Working with Standard Buttons https://docs.oracle.com/en/cloud/saas/netsuite/ns-online-help/bridgehead_N2857736.html I have the "native" approve action as "button" and to be shown, yet is not appearing in the form, so I am not sure yet which step I am missing
also this did not make the button appear - Purchase Order > No Approve button https://suiteanswers.custhelp.com/app/answers/detail/a_id/86464/loc/en_US
b
edit the workflow to name the button something not named approve
i vote "Battk Approves"
you wont be able to make a workflow button act like the native approve button
r
Someone was able to get both at the same time - the native and the custom --> QUICK QUESTION: PLEASE HELP : Netsuite https://www.reddit.com/r/Netsuite/comments/v0p1cc/quick_question_please_help/
but yeah I do not get the native in of my tests
b
you can have a custom button with the label approve
r
So I will resort doing another things with my custom one and the Edit context that triggers
b
it will not trigger the approve type
so it will probably confuse your users unless you hide the other
r
yeah that was clear to me. I was trying to get the native on because I was interested in getting the approve context. But I am unable to get it. Therefore I am stuck with the custom and its EDIT context. Sorry for the confusion, but I guess at the end my question can be summarized as "How do I show in the form the Native Approve Button? The one that triggers the approve context" As mention I tried this two things with no luck https://netsuiteprofessionals.slack.com/archives/C29HQS63G/p1679664314498519?thread_ts=1679563716.067979&cid=C29HQS63G https://netsuiteprofessionals.slack.com/archives/C29HQS63G/p1679664998791009?thread_ts=1679563716.067979&cid=C29HQS63G
and with this I was just testing that the fact that you have a custom button with the same name does not mean that netsuite automatically detects it and therefore hides the "native" one even when it is selected in the form. I also tested this in my account adding a different name to my custom button https://netsuiteprofessionals.slack.com/archives/C29HQS63G/p1679666821474869?thread_ts=1679563716.067979&cid=C29HQS63G
b
usually you just get the native approve button automatically
assuming you have the permission to do so
general things to do are to make sure you are working with a transaction like sales orders where the native button exists
and that the form isnt hiding the button
r
I am logged as an administrator, so not sure if that plays a factor. I am in a purchase order, where in the form is also available the action approve and reject and is checked to be shown. I am exploring other options with the custom button as I do not see a clear path on why I do not see the native button
b
i guess check that a workflow or user event isnt hiding it
else im not sure that a purchase order actually has an approve button
it only gets the status via approval routing, and thats entirely custom