RE: Is It Possible to Create Intercompany Sales Order From Intercompany Purchase Order via Scripting?
Is it possible to create Intercompany Sales Order via scripting AND not have to go to Manager Intercompany Sales Order screen to pair with Intercompany Purchase Order.
Yes, it’s possible. The script type depends on how you want to trigger it. You just have to use the APIs for creating a stand alone sales order using the values from the originating Purchase Order and add the following to your script, referencing the Purchase Order:
objRecord.setValue('intercotransaction',poId);
This is not working getting below error
INVALID_FLD_VALUE16.09.2019 13:08:23.408 {“type”:”error.SuiteScriptError”,”name”:”INVALID_FLD_VALUE”,”message”:”You have entered an Invalid Field Value 202054 for the following field: intercotransaction”,”stack”:[“<anonymous>(N/record/recordService.js)”,”<anonymous>(adhoc$-1$debugger.user:7)”,”<anonymous>(adhoc$-1$debugger.user:1)”],”cause”:{“type”:”internal error”,”code”:”INVALID_FLD_VALUE”,”details”:”You have entered an Invalid Field Value 202054 for the following field: intercotransaction”,”userEvent”:null,”stackTrace”:[“<anonymous>(N/record/recordService.js)”,”<anonymous>(adhoc$-1$debugger.user:7)”,”<anonymous>(adhoc$-1$debugger.user:1)”],”notifyOff”:false},”id”:””,”notifyOff”:false,”userFacing”:false}
Code:
require([‘N/record’, ‘N/runtime’], function (record, runtime) {
var a = record.create({type: ‘salesorder’});
a.setValue({fieldId: ‘entity’, value: 50464});
a.setValue({fieldId: ‘currency’, value: 2});
a.setValue({fieldId: ‘intercotransaction’, value: 202054});
a.save({ignoreMandatoryFields: true, enableSourcing: true});
});

This could be due to multiple reasons. Check if this PO transaction is indeed eligible for creating an intercompany transaction for. You also have to make sure that the entity you’re setting is the intercompany entity of the Purchase Order. For more details, read SuiteAnswers ID: 20804.
Yes, the transaction is eligible as I can see that Transaction in Transactions > Sales > Manage Intercompany Sales Orders
The entity is intercompany as I already created Intercompany Sales Order using this entity from Transactions > Sales > Manage Intercompany Sales Orders
Same problem and same error here. Does anyone have a working example of creating an intercompany Sales Order from an intercompany Purchase Order via SuiteScript?

Seems that you’re right. We can’t set this field via scripting. The ‘intercotransaction’ field is blank and setting it via script throws an error. Have you guys found a solution?