Skip to main content
Solved

Commerce Connector Mapping

  • 27 December 2022
  • 1 reply
  • 122 views

Hello,

I’ve been playing around with modifier options (I know, not supported), and trying to figure out the work around.  For my purposes, mapping the product options to Transactions.NoteText is exactly where I want them. It keeps them connected to the base product without adding additional columns on my SO screen as I’ve seen on some existing customizations for this.  The problem is, I’ll have multiple modifier options aka source fields that I would want to map to the Transactions.NoteText target field.

Is there anyway to get multiple source fields to map to one target field?  I feel like I’m one line of code away from solving a major pain point for me.  

Use case: We sell made-to-order blazers for airline pilots.  Long story short, there are 160,000 possible variations so making kits, matrixes, templates is not going to work for this.  Though I am open to any other ideas.  

Thank you,

Nathan

1 reply

Userlevel 6
Badge +3

In Acumatica, it is not possible to directly map multiple source fields to a single target field using standard functionality. However, you can achieve this by creating a custom field mapping logic using event handlers, such as the FieldUpdating or RowPersisted event handlers, in your SOOrderEntry graph extension. You can use these event handlers to concatenate the values of the multiple source fields and assign the concatenated value to the target field.

For example, in the FieldUpdating event handler for the source fields, you can retrieve the current value of the target field, then concatenate the new value of the source field to the current value of the target field, and finally assign the concatenated value back to the target field.

Alternatively, you can also create a custom action that allows the user to select and map the desired source fields to the target field, and then use event handlers to perform the actual mapping.

Please note that modifying the standard behavior of Acumatica can have unintended consequences and it's always a good idea to test your customization in a non-production environment before implementing it in production.

You can use the FieldUpdated event in your SOOrderEntry graph extension to concatenate multiple source fields into the NoteText field. Here's an example of how you can do this for two source fields called "SourceField1" and "SourceField2":

public class SOOrderEntry_Extension : PXGraphExtension<SOOrderEntry>
{
protected void SOLine_SourceField1_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
{
SOLine line = (SOLine)e.Row;
cache.SetValueExt<SOLine.noteText>(line, line.SourceField1 + " " + line.SourceField2);
cache.Update(line);
}

protected void SOLine_SourceField2_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
{
SOLine line = (SOLine)e.Row;
cache.SetValueExt<SOLine.noteText>(line, line.SourceField1 + " " + line.SourceField2);
cache.Update(line);
}
}

This code updates the NoteText field of the SOLine whenever either of the two source fields are updated. The SetValueExt method is used to set the value of the NoteText field, and the Update method is used to persist the changes to the database.

You can also add any other fields you want to concatenate into the NoteText field.

Keep in mind that this code is updating the NoteText field on SOLine whenever the source fields are updated. If you have other logic that also updates the NoteText field, it may be overwritten by this code.

Reply