I've got a question about how to set the value of manually-added line item select fields. I have a select field that I add on the "beforeLoad" user-event server-side SuiteScript to the line item. This code adds a new select field and then populates the select field with some data. Then I want to select a value from that select field. I do that using the client-side Page Init function. This code loops through the line items and sets the value of my custom field. The problem is that the line items do not change. It looks like my code doesn't even run. Here's some snippets. I am on the sales order page, and am manually adding a select field that lists milestones for this sales order. Each line item has a task linked to it so the user can select a milestone for that line item, and on save the milestone is set on that task. So on page init, I want to get the task and get the milestone (if any) from that task and set it on the line item. I wanted to create a custom field that would source from the milestones on the order automatically but that wasn't available so I am attempting to do it manually.
BeforeLoad function:
function BeforeLoad(type, form) { var sublist = form.getSubList('item'); var select = sublist.addField('custpagemilestones', 'select', 'Milestone'); select.addSelectOption('', '', false); var count = nlapiGetLineItemCount('billingmilestones'); for (var i=1; i&lt;=count; i++) { var id = nlapiGetLineItemValue('billingmilestones', 'milestoneid', i); var title = nlapiGetLineItemValue('billingmilestones', 'milestonename', i); select.addSelectOption(id, title, false); } // end for } // end function Page Init function:('custcollineitemtaskid' is the name for my custom column field that stores the taskId associated with this line item) function PageInit(type) { var count = nlapiGetLineItemCount('item'); for (var i=1; i&lt;= count; i++) { var taskId = nlapiGetLineItemValue('item', 'custcollineitemtaskid', i); if (taskId != null && taskId != -1 && taskId != '') { var task = nlapiLoadRecord('task', parseFloat(taskId)); var milestoneId = task.getFieldValue('milestone'); if (milestoneId != "" && milestoneId != -1 && milestoneId != null) { <span style="color:'"Red"'">nlapiSetLineItemValue('item', 'custpagemilestones', i, milestoneId);</span> } } } } Everything works fine except that nothing happens when the line in red is called. I know that the taskId is set and that it finds a milestoneId so the line in red is definitely being called. Is there something I need to do reload the line items? I know that there is a function called nlapiRefreshLineItems(type) but when I call that I get a javascript error that that function is not defined. Any ideas would be appreciated. Thanks.