rudler
05/07/2020, 7:58 PM// JavaScript Document
var search = nlapiLoadSearch('transaction', 'customsearch_nsts_vp_prepayments_on_ho_2')
var res = search.runSearch()
res.forEachResult(function(searchResult){
var = rec_id = searchResult.getValue('internalid')
var bill = nlapiLoadRecord('vendorbill', rec_id);
var totalCount = bill.getLineItemCount('item');
var project = nlapiLoadRecord('vendorbill', 'custbody_ref_proj_for_app.internalid');
for (var index = 1; index <= totalCount; ++index) {
// Your intended update code
for (var i=0; i < numLines ; i++) {
// setting on line i the custom field value
curRec.setSublistValue({
sublistId: 'expense',
fieldId: '{job.internalid}',
line: i,
value: Project
});
}
}
nlapiSubmitRecord(bill, false, true);
return true
})battk
05/07/2020, 8:53 PMvar = rec_id = searchResult.getValue('internalid')
battk
05/07/2020, 8:53 PMbattk
05/07/2020, 8:55 PM'custbody_ref_proj_for_app.internalid'
is not a valid internal id for a vendorbill
var project = nlapiLoadRecord('vendorbill', 'custbody_ref_proj_for_app.internalid')
battk
05/07/2020, 8:58 PMbattk
05/07/2020, 8:59 PMstalbert
05/07/2020, 9:00 PMbattk
05/07/2020, 9:01 PMfor (var i = 1; i <= totalCount; ++i) {
stalbert
05/07/2020, 9:01 PMforEach
expresses intent with a well known name and semantics.stalbert
05/07/2020, 9:04 PMbattk
05/07/2020, 9:06 PMcurRec.setSublistValue({
sublistId: "expense",
fieldId: "{job.internalid}",
line: i,
value: Project,
});
but the field internal id is incorrect, and there is no variable named Projectrudler
05/22/2020, 12:32 PM