I have written a script which creates a billing schedule record for items on the creation of sales order using afterSubmit() user event script.
The billing schedule record gets created for every item,but it also should be set in line level field 'billing schedule' of the sales order.details in
attachment
var rec =nlapiCreateRecord('billingschedule');
var res = itemname.substring(0, 40);
rec.setFieldValue('name',res);
rec.setFieldValue('initialamount',itemamount);
rec.setFieldValue('numberremaining','5');
rec.setFieldText('frequency','Daily');
var sub = nlapiSubmitRecord(rec,true);
if(sub!=null)
{
nlapiSetLineItemValue('item','billingschedule',i+1,sub);
}