Hi all
Having some trouble here. The below code throws up an error saying - "RCRD_DSNT_EXIST","message":"There are no records of this type".
Here is the problem as I see it. Some has pointed out to me that the record ID needs to be the internal ID of the item I am running the script against.
This makes 0 sense. I don't want to run the workflow against 1 item, the workflow is already configured to perform actions on multiple items.
All I am trying to do here is trigger this workflow to run when another type of record (goods receipt) is created, because of the ridiculous flaw of only being able to have a scheduled workflow run once every 30 minutes.
Any help greatly appreciated, sorry if I sound irate but what I am trying to accomplish seems relatively straightforward to me. I'm actually disappointed that I am having to use a script at all.
Why is is not possible to trigger a workflow from a workflow on another record type?
Code is below. Thank you. Oliver
/**
* @NApiVersion 2.x
* @NScriptType UserEventScript
*/
define(['N/workflow', 'N/search', 'N/error', 'N/record'],
function (workflow, search, error, record) {
function initiateWorkflow(scriptContext) {
var workflowInstanceId = workflow.initiate({
recordType: 'inventoryitem',
recordId: 35,
workflowId: 'customworkflow14'
});
var inventoryitemRecord = record.load({
type: record.Type.INVENTORY_ITEM,
id: 35
});
}
return {
afterSubmit: initiateWorkflow
};
});