Import Optional fields using Interop SDK for AR

SUGGESTED

Hi, Can any one help on this optional field in .Net API

Problem: Optional field can't be inserted. Only the tick mark can be viewed in AR invoice entry UI screen

Source code:

ARINVOICE1detail4.RecordClear();
ARINVOICE1detail4.RecordCreate(ViewRecordCreate.NoInsert);
ARINVOICE1detail4.Process();
ARINVOICE1detail4.Fields.FieldByName("CNTLINE").SetValue(0, false);
ARINVOICE1detail4.Fields.FieldByName("OPTFIELD").SetValue("YEAR", false);
////ARINVOICE1detail4.Read(false);
ARINVOICE1detail4.Fields.FieldByName("VALIFTEXT").SetValue("2021", false);
ARINVOICE1detail4.Insert();
ARINVOICE1detail4.Read(true);
ARINVOICE1detail4.RecordCreate(0);

Parents
  • 0
    SUGGESTED

    Assuming that your view compositions are correct, the code below should give you some ideas.  You'll have to adapt it to your language but the function calls below show you how to look for an existing optional field record and create it if required. 

    DetailOptFld is the view, aOptField is the optional field code, and aValue is the value to assign to the optional field.  In my code it is a variant data type which is why I use the fancy VALINDEX field value to figure out which field to assign the value to.


        With DetailOptFld
            .RecordClear
            .Fields("OPTFIELD").PutWithoutVerification aOptField

            If Not (.Read) Then
                .RecordCreate VIEW_RECORD_CREATE_DELAYKEY
                .Fields("OPTFIELD").value = aOptField
                .Fields("SWSET").value = "1"
            End If

            .Fields.FieldByID(.Fields("VALINDEX").value) = aValue

            If .Exists Then
                .Update
            Else
                .Insert
            End If

        End With
Reply
  • 0
    SUGGESTED

    Assuming that your view compositions are correct, the code below should give you some ideas.  You'll have to adapt it to your language but the function calls below show you how to look for an existing optional field record and create it if required. 

    DetailOptFld is the view, aOptField is the optional field code, and aValue is the value to assign to the optional field.  In my code it is a variant data type which is why I use the fancy VALINDEX field value to figure out which field to assign the value to.


        With DetailOptFld
            .RecordClear
            .Fields("OPTFIELD").PutWithoutVerification aOptField

            If Not (.Read) Then
                .RecordCreate VIEW_RECORD_CREATE_DELAYKEY
                .Fields("OPTFIELD").value = aOptField
                .Fields("SWSET").value = "1"
            End If

            .Fields.FieldByID(.Fields("VALINDEX").value) = aValue

            If .Exists Then
                .Update
            Else
                .Insert
            End If

        End With
Children