Setting Custom Form Field Values for Sales Orders in SYSPRO

Overview

CyberStore supports integration with SYSPRO Custom Form Fields (CFFs) to enable storing user-defined data directly onto SYSPRO records such as Sales Orders. This guide describes how to programmatically update a CFF on a Sales Order using the SetCustomField method from the CustomFieldDataAccess class.

The method handles compatibility with SYSPRO versions prior to 7.0 and 7.0 or later, abstracting the differences in required parameters and XML schema between the COMSFM and COMTFM business objects.

This guide focuses specifically on setting values. Retrieving CFFs is covered separately.

In this Topic

Prerequisites

Before implementing the logic, ensure:

  • A custom form field (CFF) is defined in SYSPRO for the Order functional area (FormType = “ORD”).
  • The CyberStore SYSPRO session is properly initialized.
  • The CustomFieldDataAccess class is available in your project.
  • The following import directives are added to your .ascx file:
<%@ Import Namespace="Dovetail.Ecommerce.Syspro.DataAccess" %>
<%@ Import Namespace="Dovetail.Ecommerce.Module" %>

Method Signature

public static XmlDocument SetCustomField(
    string FormType,
    string KeyField,
    string FieldName,
    string Value,
    string ValueType,
    bool isAdd = false,
    Dictionary<string, string> KeyFields7 = null,
    string ColumnName = ""
)

Usage Example

This example demonstrates how to statically assign a value to a Sales Order-level Custom Form Field (CFF) using the SetCustomField method. It retrieves the order number via the standard CyberStore CheckOut module.

To add the CFF, you will need to create a custom instance of the ChecOutDisplayOrderReceipt.ascx control in your site, which will execute the code on page load.

Code Example

<%@ Import Namespace="Dovetail.Ecommerce.Syspro.DataAccess" %>
<%@ Import Namespace="Dovetail.Ecommerce.Module" %>

<script runat="server">
    protected override void OnLoad(EventArgs e)
    {
        try
        {
            // Step 1: Get the CheckOut instance
            Dovetail.Ecommerce.Module.CheckOut checkOutInstance = Dovetail.Ecommerce.Module.CheckOut.Instance;

            // Step 2: Retrieve the current order number
            string orderNumber = checkOutInstance.GetOrderNumber();

            // Example static value to assign to the custom form field
            string customValue = "12";

            // Set the custom form field value on the order
            CustomFieldDataAccess.SetCustomField(
                "ORD",                          // FormType: Sales Order area
                "SalesOrder",                   // KeyField (used in SYSPRO < 7.0)
                "FRE001",                       // FieldName (used in SYSPRO < 7.0)
                customValue,                    // Value to assign to the CFF
                "NUMERIC",                      // ValueType: ALPHA, NUMERIC, or DATE
                false,                          // isAdd: true = add; false = update
                new Dictionary<string, string>  // KeyFields7: required for SYSPRO 7+
                {
                    { "SalesOrder", orderNumber }
                },
                "FreightLevel"                  // ColumnName: SYSPRO 7+ field name
            );
        }
        catch (Exception ex)
        {
            ErrLog.ProcessError(
                "CFF", 7, "200",
                String.Format("Error updating CFF for Sales Order. {1}", ex.Message),
                ex.StackTrace
            );
        }
        finally
        {
            base.OnLoad(e);
        }
    }
</script>

Parameter Details

Parameter Required Description
FormType Yes SYSPRO functional area code. For orders, use "ORD".
KeyField Yes Used for SYSPRO < 7.0. Set to "SalesOrder" for order-level CFFs.
FieldName Yes Internal SYSPRO field name (e.g., "FRE001").
Value Yes The data to store in the CFF.
ValueType Yes One of: "ALPHA", "NUMERIC", or "DATE".
isAdd No true to insert, false to update. Defaults to false.
KeyFields7 No Required for SYSPRO 7+. Dictionary of key-value pairs.
ColumnName No Required for SYSPRO 7+. Visible column name in SYSPRO.

SYSPRO Version Behavior

SYSPRO Version Business Object Used Required Parameters
Prior to 7.0 COMSFM FormType, KeyField, FieldName, Value, ValueType, isAdd
7.0 or newer COMTFM FormType, KeyFields7, ColumnName, Value, isAddNote: KeyField, FieldName, and ValueType must still be sent as placeholders.

Error Handling

If a required field is missing or an invalid ValueType is passed, an exception will be logged using ErrLog.ProcessError. Ensure robust error capture during development and testing.

Additional Reading


This site uses Just the Docs, a documentation theme for Jekyll.