Reputation: 37
I have been working with the event sublist. I need to set the values of the attendees using a user event scipt which is deployed for before load. This script executes only for the new records created. I am able to successfully set the attendee values with other parameters.
Problem is when the for loop iterates then every time there is a alert coming saying that "Please enter a value for send invitation to".
Though the values are set properly but this alert comes as many times as the employees are set as attendee.
Below is the code snippet for the same.
for(var i = 0;i<results.length;i++) {
var searchresult = results[ i ];
var record = searchresult.getId();
nlapiSelectNewLineItem('attendee');
nlapiSetCurrentLineItemValue('attendee','attendee',record);
nlapiSetCurrentLineItemValue("attendee", "response", "NORESPONSE");
nlapiSetCurrentLineItemValue("attendee", "attendance", "OPTIONAL");
nlapiCommitLineItem("attendee");
}
May I know how can i make this alert stop?
And one thing : If I deploy this script for after submit then it works absolutely fine with no alert. But the business requirement is to run it for before load function.
Thanks Rahul
Upvotes: 1
Views: 698
Reputation: 8902
Have you tried the non-dynamic API for working with sublists? Try rewriting your loop as:
for (var i = 0; i < results.length; i++) {
var lineIndex = i + 1;
nlapiSetLineItemValue('attendee','attendee', lineIndex, results[i].getId());
nlapiSetLineItemValue("attendee", "response", lineIndex, "NORESPONSE");
nlapiSetLineItemValue("attendee", "attendance", lineIndex, "OPTIONAL");
}
Upvotes: 2