tyeatman wrote:Thank you for the responses.
I have used your solution below, and the note is still being created with the default note type.
- Code: Select all
salesOrderPOSTRequest.Notes.Add(new JiwaFinancials.Jiwa.JiwaServiceModel.Notes.Note()
{
NoteType = new JiwaFinancials.Jiwa.JiwaServiceModel.Notes.NoteType() { NoteTypeID = "0dc3cf6d-92eb-4854-8548-52275034e350" },
NoteText = strComment.ToString()});
If I try it with {Description = "My Note Description"} it errors when making the Order post request with 'Object variable or With block variable not set
Tony
Ok, so I found a bug when using the Description for the NoteType instead of the NoteTypeID - it produces the error as you describe. The logic does try to resolve the NoteType with the Description if NoteTypeID is provided, but it incorrectly then tried to compare NoteTypeID in the DTO with the Description of known notes, which caused the exception.
Logged as
DEV-8233.
Providing the NoteTypeID instead should still work - if it saves using the default NoteType instead, then it has to be because it does not receive a NoteType in the DTO, or that part of the DTO does not have a NoteTypeID in it.
Below is the code we use to deserialise a Note when we're POSTing or PATCHing notes everywhere - it's the same code for sales orders, inventory, and everywhere else which has notes (still has the erroneous attempt to get a NoteType using NoteTypeID instead of Description if NoteTypeID is not provided).
- Code: Select all
Public Sub DTO_Deserialise(ByVal Note As JiwaServiceModel.Notes.Note) Implements IJiwaDTODeserialisable(Of JiwaServiceModel.Notes.Note).DTO_Deserialise
OnDTODeserialiseStart(Note)
If Note.NoteText IsNot Nothing Then
NoteText = Note.NoteText
End If
If Note.LineNo IsNot Nothing Then
ItemNo = Note.LineNo
End If
If Note.LastSavedDateTime IsNot Nothing Then
LastSavedDateTime = Note.LastSavedDateTime
End If
If Note.NoteType IsNot Nothing Then
Dim noteType As JiwaApplication.Notes.NoteType = Nothing
If Note.NoteType.NoteTypeID IsNot Nothing AndAlso Note.NoteType.NoteTypeID.Trim.Length > 0 Then
noteType = NoteCollection.NoteTypeCollection.Item(Note.NoteType.NoteTypeID)
If noteType Is Nothing Then
Throw New JiwaApplication.Exceptions.RecordNotFoundException(String.Format("NoteType with RecID '{0}' was not found.", Note.NoteType.NoteTypeID))
End If
Me.NoteType = noteType
ElseIf Note.NoteType.Description IsNot Nothing Then
noteType = NoteCollection.NoteTypeCollection.GetItem("Description", Note.NoteType.NoteTypeID)
If noteType Is Nothing Then
Throw New JiwaApplication.Exceptions.RecordNotFoundException(String.Format("NoteType with Description '{0}' was not found.", Note.NoteType.Description))
End If
Me.NoteType = noteType
End If
End If
If Note.LastModifiedByStaffID IsNot Nothing AndAlso Note.LastModifiedByStaffID.Trim.Length > 0 Then
Me.LastModifiedByStaffMember.ReadRecord(Note.LastModifiedByStaffID)
ElseIf Note.LastModifiedByStaffUsername IsNot Nothing AndAlso Note.LastModifiedByStaffUsername.Trim.Length > 0 Then
Me.LastModifiedByStaffMember.ReadRecordByUsername(Note.LastModifiedByStaffUsername)
End If
OnDTODeserialiseEnd(Note)
End Sub
If you have defined any request filters, they might be stripping stuff out - but if not then perhaps a custom plugin or something is overriding your note type?