3

I tried to trigger a workflow programatically,

nlapiTriggerWorkflow(recType, recId, workflowId, actionId, stateId)

But I am getting,

"nlapiTriggerWorkflow" is not defined

both in console and in script debugger. Why do I get this error?

Ajith V
  • 53
  • 5

2 Answers2

1

The issue is that nlapiTriggerWorkflow is server side only. If you want to trigger a workflow client side you can add a button to the preceding work flow step (see the docs) and trigger your workflow from that.

bknights
  • 14,408
  • 2
  • 18
  • 31
0

Maybe this is happening because you are trying to use Suitescript 1.0 API in Suitescript 2.0

If you are using Suitescript 2.0 (or if it is feasible to switch to Suitescript 2.0), you can try this -

var workflowInstanceId = workflow.trigger({
  recordType: 'salesorder',
  recordId: 1234,
  workflowId: 'custworkflow_name',
  defaultValues: p
  actionId: workflowaction25
});

In case of issues, just search for workflow.trigger(options) in the SuiteAnswers.

Let me know.

Sayeesh
  • 208
  • 1
  • 3
  • 13
  • Hi, thanks for the answer, but I am adding the code in an inline field, so can't use the ss2.0. Also, ss1.0 commands like nlapiSubmitField works fine, so i dont think that is the issue here. – Ajith V Dec 23 '21 at 07:41