I have two custom records with parent child relati...
# suitescript
p
I have two custom records with parent child relationship. I'm working in SS1.0 looking to add roughly 900 of the child records on by a scheduled script, is there a way I can somehow treat the child as line items to bypass the governance requirements?
n
Load the parent as dynamic and select a new line, set the child details, commit the line and then save the parent when you've added all children. @Paul_s
The governance for adding sublist lines is 0
p
Thanks, Will look into dynamic mode, not familiar with that at present. Would the standard record.selectNewLineItem etc work with the parent child record setup?
n
Yes. You will find the sublist is named something like recmachcustrecord_<restoftheid>
p
Thanks, will give it a whirl now
n
@Paul_s Look in help at "Finding the Internal ID of a Custom Child Record Sublist"
If your script is new I'd recommend SS2.0 too, break away from the legacy API. 😉
p
I'd love too, somehow whenever a scripting project comes up the deadline is always too tight to look into it!
Sorry, do you mind having a quick look at where i'm going wrong here, the script ran without any failures, but the child records were not created. Parent record ID: customrecord_gc_rhenus_stock_rec_results Child record ID: customrecord_gc_rhenus_recon_res_line Child record link to the parent id: custrecord_gc_rhenus_stock_rec_parent
var record = nlapiLoadRecord("customrecord_gc_rhenus_stock_rec_results", recID);
for(var i = 0, len = variances.length; i < len; i ++) {
record.selectNewLineItem('rechmachcustrecord_gc_rhenus_stock_rec_parent');
record.setCurrentLineItemValue('customrecord_gc_rhenus_recon_res_line', 'custrecord_gc_rhenus_stock_rec_sku', variances[i]['sku']);
record.commitLineItem('rechmachcustrecord_gc_rhenus_stock_rec_parent');
}
nlapiSubmitRecord(record, true);