Skip to main content
Question

Sales Order line item notes

  • January 11, 2023
  • 5 replies
  • 432 views

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

5 replies

Forum|alt.badge.img+6
  • Captain II
  • 576 replies
  • January 11, 2023

What have you tried so far?


  • Freshman I
  • 3 replies
  • January 15, 2023

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. 


  • Author
  • 4 replies
  • January 16, 2023
mray56 wrote:

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.. 
 


  • Author
  • 4 replies
  • January 19, 2023
ddunn wrote:

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);
        }
      }
    }
  }


Chris Hackett
Community Manager
Forum|alt.badge.img
  • Acumatica Community Manager
  • 2782 replies
  • March 16, 2023

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


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings