I have issues with setting percent fields through NFT SS2. See below. I receive a NetSuite error when I use the commented out NFT code below, saying that I am giving it an invalid value. Falling back to the nsrecord functions does run without error,
// Load the Project to make updates requested by the custom application
let project = new Study(+projectId)
// Loop through each update to find the related Percent Complete Override record to update.
.forEach(updatedNeeded, function(appData){
log.debug("App Data first Obj", appData)
let lineCount = project.nsrecord.getLineCount({ sublistId: 'percentcompleteoverride' })
log.debug('Current LINE COUNT', lineCount)
let lineToUpdate = .findIndex(project.percentcompleteoverride, function(ld){ return ld.period == appData.period; })
log.debug("Line Found to Update", lineToUpdate)
if (lineToUpdate > -1){
log.debug("Line FOUND to update", lineToUpdate)
//project.percentcompleteoverride[lineToUpdate].comments = "UPDATED BY COST APP" // TODO: Remove after demo and internal testing
//project.percentcompleteoverride[lineToUpdate].percent = appData.updPercComplete.trim()
project.nsrecord.setSublistValue({ sublistId: 'percentcompleteoverride', line: lineToUpdate, fieldId: 'percent', value: appData.updPercComplete.trim() })
project.nsrecord.setSublistValue({ sublistId: 'percentcompleteoverride', line: lineToUpdate, fieldId: 'comments', value: "Override by Mgr" })
log.debug("PERCENT OVERRIDDEN", appData.updPercComplete.trim())
} else {
log.debug("No line found to update", appData.period + " -- " + appData.updPercComplete)
//let newOverride = project.percentcompleteoverride.addLine()
//newOverride.period = appData.period
//newOverride.comments = "ADDED BY RSM COSTAPP" // TODO: Remove after demo and internal testing
//newOverride.percent = appData.updPercComplete.trim()
project.nsrecord.setSublistValue({ sublistId: 'percentcompleteoverride', line: lineCount, fieldId: 'percent', value: appData.updPercComplete.trim() })
project.nsrecord.setSublistValue({ sublistId: 'percentcompleteoverride', line: lineCount, fieldId: 'comments', value: "New Override by Mgr" })
project.nsrecord.setSublistValue({ sublistId: 'percentcompleteoverride', line: lineCount, fieldId: 'period', value: appData.period })
log.debug("PERCENT OVERRIDDEN 2", appData.updPercComplete)
}
})
I have issues with setting percent fields through NFT SS2. See below. I receive a NetSuite error when I use the commented out NFT code below, saying that I am giving it an invalid value. Falling back to the nsrecord functions does run without error,
// Load the Project to make updates requested by the custom application let project = new Study(+projectId) // Loop through each update to find the related Percent Complete Override record to update. .forEach(updatedNeeded, function(appData){ log.debug("App Data first Obj", appData) let lineCount = project.nsrecord.getLineCount({ sublistId: 'percentcompleteoverride' }) log.debug('Current LINE COUNT', lineCount) let lineToUpdate = .findIndex(project.percentcompleteoverride, function(ld){ return ld.period == appData.period; }) log.debug("Line Found to Update", lineToUpdate) if (lineToUpdate > -1){ log.debug("Line FOUND to update", lineToUpdate) //project.percentcompleteoverride[lineToUpdate].comments = "UPDATED BY COST APP" // TODO: Remove after demo and internal testing //project.percentcompleteoverride[lineToUpdate].percent = appData.updPercComplete.trim() project.nsrecord.setSublistValue({ sublistId: 'percentcompleteoverride', line: lineToUpdate, fieldId: 'percent', value: appData.updPercComplete.trim() }) project.nsrecord.setSublistValue({ sublistId: 'percentcompleteoverride', line: lineToUpdate, fieldId: 'comments', value: "Override by Mgr" }) log.debug("PERCENT OVERRIDDEN", appData.updPercComplete.trim()) } else { log.debug("No line found to update", appData.period + " -- " + appData.updPercComplete) //let newOverride = project.percentcompleteoverride.addLine() //newOverride.period = appData.period //newOverride.comments = "ADDED BY RSM COSTAPP" // TODO: Remove after demo and internal testing //newOverride.percent = appData.updPercComplete.trim() project.nsrecord.setSublistValue({ sublistId: 'percentcompleteoverride', line: lineCount, fieldId: 'percent', value: appData.updPercComplete.trim() }) project.nsrecord.setSublistValue({ sublistId: 'percentcompleteoverride', line: lineCount, fieldId: 'comments', value: "New Override by Mgr" }) project.nsrecord.setSublistValue({ sublistId: 'percentcompleteoverride', line: lineCount, fieldId: 'period', value: appData.period }) log.debug("PERCENT OVERRIDDEN 2", appData.updPercComplete) } })
project.save() log.debug('Project Re-saved', projectId)