Customize Sales Order to add notes per line item based on the product modifiers from BC
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);
}
}
}
}
Reply
Enter your username or e-mail address. We'll send you an e-mail with instructions to reset your password.