Question

Sales Order line item notes

  • 11 January 2023
  • 5 replies
  • 277 views

Customize Sales Order to add notes per line item based on the product modifiers from BC


5 replies

Userlevel 7
Badge +5

What have you tried so far?

You don’t need customization for this you can use the custom mapping on entities(Sales order in this case).

Here is a link that covers the general idea. In this post they are using a custom field but you can also map it to the note field as well. 

You don’t need customization for this you can use the custom mapping on entities(Sales order in this case).

Here is a link that covers the general idea. In this post they are using a custom field but you can also map it to the note field as well. 

Hi, thank you for your response..  but I have multiple modifiers (dropdown) from Bigcommerce.. and column is kind of messy when it comes to other products that don’t have those options.. 
 

What have you tried so far?

I have tried one customization and trying to make some edit, but I can’t seem to make it work updating notes. 

I’m planning to remove the custom field and replace with notes per line items and grab all product options and save it on per line item..

 

public class BCSalesOrderProcessorExt : PXGraphExtension<BCSalesOrderProcessor>
  {
    public delegate void SaveBucketImportDelegate(BCSalesOrderBucket bucket, IMappedEntity existing, String operation);

    [PXOverride]
     public virtual void SaveBucketImport(BCSalesOrderBucket bucket, IMappedEntity existing, String operation, SaveBucketImportDelegate baseMethod)
      {
      MappedOrder order = bucket.Order; //Object of the sales order
        
      //Extern is the API Object from BigCommerce
      for (int i = 0; i < (order.Extern.OrderProducts?.Count ?? 0); i++) 
      {
        OrdersProductData data = order.Extern.OrderProducts[i];
        //Local is the API Object from Acumatica
        SalesOrderDetail detail = order.Local.Details.Where(x => x.Delete != true).Skip(i).Take(1).FirstOrDefault(); 
        if(detail != null)
        {
          List<CustomField> fields = new List<CustomField>();
          GetCustomField(fields, data, "Message", "Transactions", "UsrMessageText"); //UsrMessageText is the name of the custom field

          if (fields.Count > 0) detail.Custom = fields; //Here we place custom fields to Acumatica API object. Rest well be handled automatically.     
        }
      }
        baseMethod(bucket, existing, operation); // calling the base met
    }

    public virtual void GetCustomField(List<CustomField> result, OrdersProductData data, String optionName, String objectName, String fieldName)
    {
      if (data?.ProductOptions != null)
      {
        string displayValue = string.Empty;
        foreach (var option in data.ProductOptions) //BigCommerce Object already contains options, we just need to go though them
        {
          if (option.DisplayValue != null)
          {
            displayValue += option.DisplayName + ":" + option.DisplayValue + "\r\n";
          }
        }
  
        if(displayValue != null){
          
          // HERE I AM TRYING TO ADD SETNOTE BUT I CANT MAKE IT WORK SINCE THERE IS NO PXCACHE
          //PXNoteAttribute.SetNote(PXCache, data, displayValue);  
          
          CustomStringField field = new CustomStringField()
            {
              ViewName = objectName, //Dataview name for the sales order details
              FieldName = fieldName, //Custom field name
              Value = new StringValue() { Value = displayValue } // Custom field value
            };
          result.Add(field);
        }
      }
    }
  }

Userlevel 7
Badge

Hi @verbs91  were you able to find a solution? Thank you!

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved