Hi,
I am trying to extend the end date on a line item in a service contract via the DI and it is giving me the following error: 'Item's end date cannot be greater than contract's end date' and I don't understand why.
I retrieve the service contract object, change the header end date then find the line item I need, update it with the same end date and then issue call the SC update method. Here's my code:
Try SC.Lines.SetCurrentLine(SerialNbrLineNumber) NewStartDate = LineEndDate 'calculate new end date & extend service contract NewEndDate = NewStartDate.AddYears(Warranty_Duration) 'never make the contract end date earlier than it had been SC.EndDate = IIf(NewEndDate > SC.EndDate, _ NewEndDate, _ SC.EndDate) 'update service contract detail with new end date If NewEndDate > LineEndDate Then SC.Lines.EndDate = NewEndDate End If If SC.Update() <> 0 Then rs.RtnCode = -1 rs.RtnMessage = B1Comp.GetLastErrorDescription() End If
I did see something in the di help that mentions that B1 calcs an end date based on the "duration of coverage" field but I don't think I could use that because I might only change the end date for one line item.
BTW I can do this in the application with no problem.
Thanks in advance for any assistance.