[Order Entry - Misc Item - .NET] Misc Item Extended Amount is always set at zero...

SOLVED

Hello there!

I need to add new Orders Entry through code. Everything is working fine, but now I need to add some Misc Item to new Orders Entry. I can successfully create new Orders, but my Misc Item Extended Cost(EXTINVMISC) is always set at zero. I need to be able put my own amount.

If I try to write it directly like this: 

OEORD1detail.Fields.Item("EXTINVMISC").Set_Value(customAmount);

I receive a Read-Only error, which is normal, because an Item's extended amount cannot be set manually, but for a Misc Item, this is the only field available to write the amount. If I try to do directly in Sage 300 ERP and create a Order Entry, I can change the Extended Amount of a Misc item without any problem. 

I don't know what I am missing with the AccpacView? Is there any documentation about inserting Misc Item through the SDK? 

  • 0
    You made a simple mistake, check your code. Or do another recording and compare.
  • 0 in reply to Jay Converse Acumen
    Simple mistake? what is it? Okay, I made a mistake while writing my post. "Set_Value" should be "set_value". ^^'

    The real line looks like this: OEORD1detail1.Fields.Item(col.ColumnName).set_Value(row[col.ColumnName]);

    Am I writing the data in the right column? At first I was using the same column for Regular Item Entry, but sadly, wasn't effective at all for my Misc Item.

    LINETYPE is set to 2, the item code(MISCCHARGE) is also set. I left the regular item code(ITEM) blank and quantity empty.

    I tried multiple possibilitys, but all was in vain.
  • 0 in reply to PMCDC
    You only posted one line of code, your simple mistake is elsewhere. I've coded this many, many times and never had this issue. Do a recording of a MISC insert and compare.
  • 0
    You'll need to show more code. If you're not adding a new record first but, instead, accidentally trying to update the existing item row then the extended price field will be read-only.
  • 0
    EXTINVMISC is a read only field, sey qty and unit price.
  • 0 in reply to 49153
    EXTINVMISC is not read-only. Here is a snippet from production code:

    If recDetail.Fields("linetype") = 2 Then
    OEOrderDetail.Fields("MISCCHARGE") = recDetail.Fields("misccharge")
    OEOrderDetail.Fields("PROCESSCMD") = "1"
    OEOrderDetail.Process
    OEOrderDetail.Fields("EXTINVMISC") = recDetail.Fields("UnitPrice")
    OEOrderDetail.Insert
    bLines = True
    Else
    ...
  • 0 in reply to Jay Converse Acumen

    I tried to set UnitPrice and Quantity, but it wasn't working.

    Okay, well, there is the short version of my order details code:

    foreach (DataRow row in _dtDetails.Rows)
    {
    OEORD1detail1.RecordCreate(0);

    switch (System.Convert.ToInt16(row["LINETYPE"]))
    {
    case 2: //Misc Item
    OEORD1detail1.Fields.Item("LINETYPE").set_Value(row["LINETYPE"]);
    OEORD1detail1.Fields.Item("MISCCHARGE").set_Value(row["MISCCHARGE"]);
    OEORD1detail1.Fields.Item("EXTINVMISC").set_Value(row["EXTINVMISC"]); //READ ONLY EXCEPTION

    break;
    default:
    OEORD1detail1.Fields.Item("ITEM").set_Value(row["ITEM"]);
    break;

    }

    OEORD1detail1.Insert();
    System.Threading.Thread.Sleep(300);
    }

  • 0 in reply to Jay Converse Acumen

    Still no luck. Even if I use the process command, it trow the same exception.

    I don't really like posting good amount of lines of code, but there is the full part of the order details code. I tried adding the command you suggested at the end. 

              

                       foreach (DataRow row in _dtDetails.Rows)

                       {

                           OEORD1detail1.RecordCreate(0);

                           //**** Special case for Degil !

                           if ((row.Table.Columns.Contains("COMMENT1") && row["COMMENT1"] != DBNull.Value) || row["LOCATION"].ToString() == "UPC")

                           {

                               string ErrMessage = string.Empty;

                               if (ItemExists(row["ITEM"].ToString()))

                               {

                                   OEORD1detail1.Fields.Item("ITEM").set_Value(row["ITEM"]);

                               }

                               else

                               {

                                   if (ItemExists(row["ITEM"].ToString().Replace("-", "/")))

                                   {

                                       OEORD1detail1.Fields.Item("ITEM").set_Value(row["ITEM"].ToString().Replace("-", "/"));

                                   }

                                   else

                                   {

                                       if (row["UPC"] == DBNull.Value)

                                       {

                                           OEORD1detail1.Fields.Item("ITEM").set_Value(row["ITEM"]); // Must set item first

                                       }

                                       else

                                       {

                                           string ItemNo = this.GetItemNoFromUPCinComment1(row["UPC"].ToString(), ref ErrMessage);

                                           if (string.IsNullOrWhiteSpace(ItemNo))

                                           {

                                               sMessages.Add(new NegoLink.Base.Global.ErrorMessage("UPC Error", ErrMessage, "CreateOEOrder"));

                                           }

                                           else

                                           {

                                               //Load itemno from UPC contained in Comment1

                                               OEORD1detail1.Fields.Item("ITEM").set_Value(ItemNo);

                                           }

                                       }

                                   }

                               }

                           }

                           else

                           {

                               //Set Item first

                               if (row["LINETYPE"] != null)

                               {

                                   switch (System.Convert.ToInt16(row["LINETYPE"]))

                                   {

                                       case 2: //Misc Item

                                           OEORD1detail1.Fields.Item("MISCCHARGE").set_Value(row["MISCCHARGE"]);

                                           OEORD1detail1.Fields.Item("LINETYPE").set_Value(row["LINETYPE"]);

                                           break;

                                       default: //Regular Item

                                           OEORD1detail1.Fields.Item("ITEM").set_Value(row["ITEM"]);

                                           break;

                                   }

                               }

                               else

                               {

                                   //Empty = Regular Item

                                   OEORD1detail1.Fields.Item("ITEM").set_Value(row["ITEM"]);

                               }

                           }

                           if (!bIgnoreShipTo)

                           {

                               if (_Location != string.Empty)

                               {

                                   OEORD1detail1.Fields.Item("LOCATION").set_Value(_Location);// Location                  

                               }

                           }

                           foreach (DataColumn col in _dtDetails.Columns)

                           {

                               if (row[col.ColumnName] != DBNull.Value)

                               {

                                   if (col.ColumnName != "LINENUM" & col.ColumnName != "ITEM" & col.ColumnName != "UPC" & !(col.ColumnName == "LOCATION" && row["LOCATION"].ToString() == "UPC"))

                                   {

                                       if (col.ColumnName == "ORDUNIT" && Base.Global.DotsInUnits) //INVUNIT

                                       {

                                           OEORD1detail1.Fields.Item(col.ColumnName).set_Value(row[col.ColumnName] + ".");

                                       }

                                       else

                                       {

                                           if (OEORD1detail1.Fields.Item(col.ColumnName).Type == AccpacCOMAPI.tagFieldTypeEnum.FLD_DATE)

                                           {

                                               OEORD1detail1.Fields.Item(col.ColumnName).set_Value(ConvertoDate(row[col.ColumnName].ToString()));

                                           }

                                           else

                                           {

                                               if (col.ColumnName != "EXTINVMISC")

                                               {

                                                   OEORD1detail1.Fields.Item(col.ColumnName).set_Value(row[col.ColumnName]); //WRITE DATA MOSTLY HERE

                                               }

                                           }

                                       }

                                   }

                               }

                           }

                           OEORD1detail1.Fields.Item("PROCESSCMD").set_Value(1); //Don't know if its required

                           OEORD1detail1.Process();

                           if (row["EXTINVMISC"] != DBNull.Value)

                           {

                               OEORD1detail1.Fields.Item("EXTINVMISC").set_Value(row["EXTINVMISC"]);

                           }

                           OEORD1detail1.Insert();

                           System.Threading.Thread.Sleep(300);

                       }

                   }

                   catch (Exception ex)

                   {

                       if (_Session != null)

                       {

                           for (int i = 0; i <= _Session.Errors.Count - 1; i++)

                           {

                               sMessages.Add(new Global.ErrorMessage(ex.Message + Global.showInnerException(ex), _Session.Errors.Item(i), "CreateOEOrder"));

                           }

                           _Session.Errors.Clear();

                       }

                   }

  • 0 in reply to PMCDC
    Record a macro and compare it to yours.
  • 0 in reply to Jay Converse Acumen
    verified answer
    THANK YOU!!! If I could, I'll shake your hand! Recording a macro was very helpful! I'm very new with Sage, I didn't know it add this feature!

    Those two line before writing the misc item amount was mandatory

    OEORD1detail1.Fields.Item("PROCESSCMD").PutWithoutVerification(1);
    OEORD1detail1.Process();

    Thanks again Jay!

    Pierre-Marc