Hello, I have a question. I have a client script ...
# suitescript
p
Hello, I have a question. I have a client script on a custom record that writes to a corresponding vendor record. How do I get an after submit condition transaction to run for a vendor workflow after the conditions have been met? I have not been able to get it to run. Thank you.
e
You will want to set the
Event Type
on the Workflow based on the method you use to save the Vendor. If you use
save()
, you will need to make sure the
Edit
Event Type is selected on the Workflow. If you use
submitFields()
, you will need to make sure the
Direct List Edit
Event Type is selected on the Workflow. You will also want to check the
Contexts
on the Workflow to make sure that
Client
is selected (and maybe
User Interface
as well).
p
would a transition type of aftersubmit work?
e
It should
p
I have been unable to get it to trigger for the script. the transition does work when I save the record from the ui
m
Did you turn on workflow logging?
If so what does it say for the transition in the workflow logs?
p
it says the condition is not met
after the script runs
m
Is your condition a saved search condition? Or visual builder? Or formula ?
Also what function are you using in your client script to set the values and are you using recordLoad and recordSubmit
p
I am using an aftersubmit function is my script
its a virual builder condition
I am using recordload and recordsubnit
do I need to switch my script context to before submit?
m
Yes that was my first thought
It may work
Then it will ensure the client actions will be completed before the workflow
p
thank you
e
afterSubmit
is not a Client Script function. It is a
User Event
function, and that's a very important distinction. User Event scripts will not trigger other User Event scripts or Workflows
So if you have a User Event Script, you cannot trigger a User Event Workflow.
p
got it
is there a way to workaround this
m
Change your transition to before load
Note any action set to trigger On Entry into the new state will not be triggered but the record will transition
Also I think there is a. Trigger.workflow function for scripts
p
that may work better. I tried it with beforeload and it does transition. the issue is the approval status does not update
m
Can you add the approval status update as part of your script?
p
I would have to check the conditions but that should be possible
e
There is the
N/workflow
module which can initiate Workflows. I don't have experience with it myself to give further guidance there.
p
thanks! I was able to create a button and trigger it using the workflow module