Created
July 19, 2019 22:21
-
-
Save cafeasp/fdd8b777dff43009d2047c04a6815f1e to your computer and use it in GitHub Desktop.
Sales Order - Close Sales Order
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function closeSalesOrder(salesOrderInternalId) { | |
try { | |
var order = record.load({ | |
id: salesOrderInternalId, | |
type: record.Type.SALES_ORDER, | |
isDynamic: true | |
}); | |
var itemIndex = 0; | |
var itemCount = order.getLineCount({ | |
"sublistId": "item" | |
}); | |
log.debug('item count', itemCount); | |
while (itemIndex < itemCount) { | |
order.selectLine({ | |
"sublistId": "item", | |
"line": itemIndex | |
}); | |
order.setCurrentSublistValue({ | |
"sublistId": "item", | |
"fieldId": "isclosed", | |
"value": true | |
}); | |
order.commitLine({ | |
"sublistId": "item" | |
}); | |
itemIndex++; | |
} | |
var recordId = order.save({ | |
enableSourcing: false, | |
ignoreMandatoryFields: false | |
}); | |
return true; | |
} | |
catch (error) { | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment