FormulaGuidelineCheck

You can use the FormulaGuidelineCheck function to perform a guideline check for a formula by using the specified item, technical parameter, status, and context options. The function executes the GLRECHECK method by using the specified inputs and returns a data set containing the guideline check results.

Note: The object key, item, technical parameter, status, and context options are taken as input.

When to use

You can use this function to check formulas against guidelines during workflow approval processes.

When not to use

You cannot use this function if it is specific to a formula.

Syntax

object FormulaGuidelineCheck(string objectkey, Dictionary<string, string> guidelineCheckOptions, Dictionary<string, object> contextOptions);

Parameters

Parameter Type Required Description
objectKey String Yes The key of the object.
Note: 
  • You can use the empty quotation marks [“”] for the current workflow object.
  • If this parameter is empty, the current object is taken as the default value.
  • If the parameter is invalid, the function returns no data.
guidelineCheckOptions Dictionary<string, string> No

The list of KeyValuePair objects, where:

  • The key is the item, parameter, and status options code in the Guideline Checkform.
  • The value is the selection state of check boxes. Possible values:
    • 1- Selected
    • 0 - Unselected
contextOptions Dictionary<string, object> No

The list of KeyValuePair objects, where:

  • The Key is the context type (Key = Context Type)
  • The value is an Array (Value = [Selection State, Context Attribute Values])
Note: The first value is the selection state of the Include Context check box.
Note: 

If guidelineCheckOptions and contextOptions are not specified, the input is taken as the default option, and the resultant data set is returned.

Return Value

The application returns a data set object containing the guideline check results.

GuidelineCheckOptions

Option Name (Key) Description Values
SHOWITEMIND Show item guidelines

Possible values:

  • "1" = Show
  • "0" = Hide
ITEMPCTIND Match formula item percentage

Possible values:

  • "1" = Match
  • "0" = Don't match
ITEMMISSINGSTMTIND Show items with undefined guidelines

Possible values:

  • "1" = Show
  • "0" = Hide
ITEMSHOWINFOSTMTIND Show informational guidelines (Items)

Possible values:

  • "1" = Show
  • "0" = Hide
SHOWTPIND Show parameter guidelines

Possible values:

  • "1" = Show
  • "0" = Hide
TPVALIND Match formula parameter value

Possible values:

  • "1" = Match
  • "0" = Don't match
TPMISSINGSTMTIND Show parameters with undefined guidelines

Possible values:

  • "1" = Show
  • "0" = Hide
TPSHOWINFOSTMTIND Show informational guidelines (Parameters)

Possible values:

  • "1" = Show
  • "0" = Hide
ITEMSTATSIND Exclude statuses for item options

Possible values:

  • "1" = Exclude
  • "0" = Include
TPSTATSIND Exclude statuses for parameter options

Possible values:

  • "1" = Exclude
  • "0" = Include
VALIDIND Limit the results to guidelines with explicitly defined context attributes

Possible values:

  • "1" = Exclude
  • "0" = Include

contextOptions

Option Name (Key/Attribute name) Description
SELLOCATION Selling location
MFGLOCATION Mfg. location
BRAND Brand
PRODTYPE Product Type
ENDUSE End Use
End Use End User

Prerequisites

  • The objectkey must be a valid formula code or empty for the current object.
  • The guidelines must be configured in the application.

Examples

Example 1
Print a message if performing FormulaGuidelineCheck on a formula FORMULA\0001 is successful and returns a non-empty data set.
using System;
using System.Data;
using System.Collections.Generic;

public class ActionScript : FcProcFuncSetEventWF
{
    public long wf_start()
    {
        // Dictionary equivalent to Dictionary(Of String, String)
        var guidelineCheckOptions = new Dictionary<string, string>
        {
            ["SHOWITEMIND"] = "1",
            ["ITEMPCTIND"] = "1",
            ["ITEMMISSINGSTMTIND"] = "1",
            ["ITEMSHOWINFOSTMTIND"] = "0",
            ["SHOWTPIND"] = "1",
            ["TPMISSINGSTMTIND"] = "0",
            ["TPSTATSIND"] = "0"
        };

        // Context options: Dictionary<string, object> with string[] values
        var contextOptions = new Dictionary<string, object>
        {
            ["SELLOCATION"] = new string[] { "1", "" },
            ["PRODTYPE"]    = new string[] { "0", "" },
            ["BRAND"]       = new string[] { "1", "Default Brand" }
        };

        // Call the guideline check function (adjust the symbol/key as needed)
        DataSet result = (DataSet)FormulaGuidelineCheck(@"FORMULA1\0001", guidelineCheckOptions, contextOptions);

        // Treat null OR an empty DataSet (no tables/rows) as "No Data"
        if (result != null && result.Tables.Count > 0 && result.Tables[0].Rows.Count > 0)
        {
            MessageList("Result has Data");
        }
        else
        {
            MessageList("Result has No Data");
        }

        return 1L;
    }
}
Description
The action gets the result data set by executing the FormulaGuidelineCheck method on FORMULA1\0001object on the FGUIDELINE symbol with different item, technical parameters, status, context options and prints the output message.
Example 2
Displaying the guideline check result for Items only.
Assuming some remote service provided UTF-16 encoded XML.
using System;
using System.Data;
using System.Collections.Generic;
using System.Text;

public class ActionScript : FcProcFuncSetEventWF
{
    public long wf_start()
    {
        // Dictionary equivalent to Dictionary(Of String, String)
        var guidelineCheckOptions = new Dictionary<string, string>
        {
            ["SHOWITEMIND"] = "1",
            ["ITEMPCTIND"] = "0",
            ["ITEMMISSINGSTMTIND"] = "1",
            ["ITEMSHOWINFOSTMTIND"] = "1",
            ["SHOWTPIND"] = "0",
            ["TPVALIND"] = "0"
        };

        // Context options: Dictionary<string, object> with string[] values
        var contextOptions = new Dictionary<string, object>
        {
            ["SELLOCATION"] = new string[] { "0", "" },
            ["MFGLOCATION"] = new string[] { "1", "" },
            ["PRODTYPE"]    = new string[] { "0", "" },
            ["BRAND"]       = new string[] { "1", "" }
        };

        try
        {
            // Call the guideline check function (empty string passed as in your VB)
            DataSet result = FormulaGuidelineCheck("", guidelineCheckOptions, contextOptions);

            // Handle null or empty result
            if (result == null)
            {
                MessageList("No G&R Results returned");
            }
            else if (!result.Tables.Contains("FSFGUIDELINERESULT") || result.Tables["FSFGUIDELINERESULT"].Rows.Count == 0)
            {
                MessageList("No G&R Results returned");
            }
            else
            {
                DataTable grResults = result.Tables["FSFGUIDELINERESULT"];
                var sb = new StringBuilder();

                foreach (DataRow grResultRow in grResults.Rows)
                {
                    string grResultTxt = grResultRow["STDSTMTTXT"]?.ToString() ?? "";
                    string grResultItem = grResultRow["OBJCODE"]?.ToString() ?? "";
                    string grResultItemName = grResultRow["OBJDESCRIP"]?.ToString() ?? "";

                    if (sb.Length > 0)
                        sb.AppendLine();

                    sb.Append(grResultItem)
                      .Append(" / ")
                      .Append(grResultItemName)
                      .Append(" = ")
                      .Append(grResultTxt);
                }

                string grResultText = sb.Length == 0 ? "No Guideline Results Returned" : sb.ToString();
                MessageList("G&R Check Results for Items: ", grResultText);
            }
        }
        catch (Exception ex)
        {
            // Log the exception message
            MessageList("G&R check exception: " + ex.Message);
        }

        return 1L;
    }
}
Description
The action gets the result data set by executing the FormulaGuidelineCheck method on the current object with different item, technical parameters, status, context options and displays the guideline result for Items only.
Example 3
Displaying the guideline check result for Parameters only.
using System;
using System.Data;
using System.Collections.Generic;
using System.Text;

public class ActionScript : FcProcFuncSetEventWF
{
    public long wf_start()
    {
        // Dictionary equivalent to Dictionary(Of String, String)
        var guidelineCheckOptions = new Dictionary<string, string>
        {
            ["SHOWITEMIND"] = "0",
            ["ITEMPCTIND"] = "0",
            ["SHOWTPIND"] = "1",
            ["TPVALIND"] = "0",
            ["TPMISSINGSTMTIND"] = "1"
        };

        // Context options: Dictionary<string, object> with string[] values
        var contextOptions = new Dictionary<string, object>
        {
            ["SELLOCATION"] = new string[] { "0", "" },
            ["MFGLOCATION"] = new string[] { "1", "" }
        };

        try
        {
            // Call the guideline check function (empty formula key as in your VB)
            DataSet Result = FormulaGuidelineCheck("", guidelineCheckOptions, contextOptions) as DataSet;

            var sb = new StringBuilder();

            if (Result == null)
            {
                MessageList("No G&R Results returned");
            }
            else
            {
                // Guard: ensure the expected table exists
                if (!Result.Tables.Contains("FSFGUIDELINERESULTPARAM") || Result.Tables["FSFGUIDELINERESULTPARAM"].Rows.Count == 0)
                {
                    MessageList("No G&R Results returned");
                }
                else
                {
                    DataTable grResults = Result.Tables["FSFGUIDELINERESULTPARAM"];

                    foreach (DataRow grResultRow in grResults.Rows)
                    {
                        string grResultTxt = grResultRow["STDSTMTTXT"]?.ToString() ?? "";
                        string grResParam = grResultRow["OBJCODE"]?.ToString() ?? "";
                        string grResParamName = grResultRow["OBJDESCRIP"]?.ToString() ?? "";

                        if (sb.Length > 0)
                            sb.AppendLine();

                        sb.Append(grResParam)
                          .Append(" / ")
                          .Append(grResParamName)
                          .Append(" = ")
                          .Append(grResultTxt);
                    }

                    string grResultText = sb.Length == 0 ? "No Guideline Results Returned" : sb.ToString();

                    // Combine a header with the result details
                    MessageList("G&R Check Results for Parameters:" + Environment.NewLine + grResultText);
                }
            }
        }
        catch (Exception ex)
        {
            // Log the exception
            MessageList("G&R check exception: " + ex.Message);
        }

        return 1L;
    }
}
Description
The action gets the result data set by executing the FormulaGuidelineCheck method on the current object with different item, technical parameters, status, context options and displays the guideline result for Parameters only.
Example 4
Displaying the guideline check result for Items and Parameters.
using System;
using System.Data;
using System.Collections.Generic;
using System.Text;

public class ActionScript : FcProcFuncSetEventWF
{
    public long wf_start()
    {
        // Dictionary equivalent to Dictionary(Of String, String)
        var guidelineCheckOptions = new Dictionary<string, string>
        {
            ["ITEMMISSINGSTMTIND"] = "1",
            ["TPMISSINGSTMTIND"] = "1"
        };

        // Context options: Dictionary<string, object> with string[] values
        var contextOptions = new Dictionary<string, object>
        {
            ["BRAND"] = new string[] { "1", "Default Brand" }
        };

        try
        {
            // Call the guideline check function (empty formula key as in your VB)
            DataSet result = FormulaGuidelineCheck("", guidelineCheckOptions, contextOptions) as Dataset;

            if (result == null)
            {
                MessageList("No G&R Results returned");
                return 1L;
            }

            var itemSb = new StringBuilder();
            var paramSb = new StringBuilder();

            // Process item results table if present
            if (result.Tables.Contains("FSFGUIDELINERESULT") && result.Tables["FSFGUIDELINERESULT"].Rows.Count > 0)
            {
                DataTable grItems = result.Tables["FSFGUIDELINERESULT"];
                foreach (DataRow row in grItems.Rows)
                {
                    string stmt = row["STDSTMTTXT"]?.ToString() ?? "";
                    string code = row["OBJCODE"]?.ToString() ?? "";
                    string descr = row["OBJDESCRIP"]?.ToString() ?? "";

                    if (itemSb.Length > 0) itemSb.AppendLine();
                    itemSb.Append(code).Append(" / ").Append(descr).Append(" = ").Append(stmt);
                }
            }

            // Process parameter results table if present
            if (result.Tables.Contains("FSFGUIDELINERESULTPARAM") && result.Tables["FSFGUIDELINERESULTPARAM"].Rows.Count > 0)
            {
                DataTable grParams = result.Tables["FSFGUIDELINERESULTPARAM"];
                foreach (DataRow row in grParams.Rows)
                {
                    string stmt = row["STDSTMTTXT"]?.ToString() ?? "";
                    string code = row["OBJCODE"]?.ToString() ?? "";
                    string descr = row["OBJDESCRIP"]?.ToString() ?? "";

                    if (paramSb.Length > 0) paramSb.AppendLine();
                    paramSb.Append(code).Append(" / ").Append(descr).Append(" = ").Append(stmt);
                }
            }

            // If both result strings are empty, no guideline results
            if (itemSb.Length == 0 && paramSb.Length == 0)
            {
                MessageList("No Guideline Results Returned");
            }

            // Log results (include header and details)
            MessageList("G&R Check Results for Items:" + Environment.NewLine + (itemSb.Length > 0 ? itemSb.ToString() : ""));
            MessageList("G&R Check Results for Parameters:" + Environment.NewLine + (paramSb.Length > 0 ? paramSb.ToString() : ""));

        }
        catch (Exception ex)
        {
            // Log the exception
            MessageList("G&R check exception: " + ex.Message);
        }

        return 1L;
    }
}
Description
The action gets the result data set by executing the FormulaGuidelineCheck method on the current object with different item, technical parameters, status, context options and displays the guideline result for Item and Parameters.
Example 5
Displaying the informational and non-informational guidelines for Parameters and Items.
using System;
using System.Data;
using System.Collections.Generic;
using System.Text;

public class ActionScript : FcProcFuncSetEventWF
{
    public long wf_start()
    {
        // Dictionary equivalent to Dictionary(Of String, String)
        var guidelineCheckOptions = new Dictionary<string, string>
        {
            ["SHOWITEMIND"] = "1",
            ["ITEMPCTIND"] = "1",
            ["ITEMMISSINGSTMTIND"] = "1",
            ["ITEMSHOWINFOSTMTIND"] = "1",
            ["SHOWTPIND"] = "1",
            ["TPVALIND"] = "1",
            ["TPMISSINGSTMTIND"] = "1",
            ["TPSHOWINFOSTMTIND"] = "1",
            ["VALIND"] = "0"
        };

        // Context options: Dictionary<string, object> with string[] values
        var contextOptions = new Dictionary<string, object>
        {
            ["SELLOCATION"] = new string[] { "1", "" },
            ["MFGLOCATION"] = new string[] { "0", "" },
            ["PRODTYPE"]    = new string[] { "1", "" },
            ["BRAND"]       = new string[] { "0", "" }
        };

        try
        {
            // Call the guideline check function (empty formula key as in your VB)
            DataSet result = FormulaGuidelineCheck("", guidelineCheckOptions, contextOptions) as DataSet;

            var itemSb = new StringBuilder();
            var paramSb = new StringBuilder();

            if (result == null)
            {
                MessageList("No G&R Results returned");
            }
            else
            {
                // Process item results table if present
                if (result.Tables.Contains("FSFGUIDELINERESULT") && result.Tables["FSFGUIDELINERESULT"].Rows.Count > 0)
                {
                    DataTable grItems = result.Tables["FSFGUIDELINERESULT"];
                    foreach (DataRow row in grItems.Rows)
                    {
                        string stmt = row["STDSTMTTXT"]?.ToString() ?? "";
                        string code = row["OBJCODE"]?.ToString() ?? "";
                        string descr = row["OBJDESCRIP"]?.ToString() ?? "";

                        // INFORMATION may be numeric or string; treat DBNull safely
                        int infoFlag = 1;
                        object infoObj = row["INFORMATION"];
                        if (infoObj != null && infoObj != DBNull.Value)
                            int.TryParse(infoObj.ToString(), out infoFlag);

                        string prefix = infoFlag == 0 ? "Restriction : " : "Information : ";

                        if (itemSb.Length > 0) itemSb.AppendLine();
                        itemSb.Append(prefix).Append(code).Append(" / ").Append(descr).Append(" = ").Append(stmt);
                    }
                }

                // Process parameter results table if present
                if (result.Tables.Contains("FSFGUIDELINERESULTPARAM") && result.Tables["FSFGUIDELINERESULTPARAM"].Rows.Count > 0)
                {
                    DataTable grParams = result.Tables["FSFGUIDELINERESULTPARAM"];
                    foreach (DataRow row in grParams.Rows)
                    {
                        string stmt = row["STDSTMTTXT"]?.ToString() ?? "";
                        string code = row["OBJCODE"]?.ToString() ?? "";
                        string descr = row["OBJDESCRIP"]?.ToString() ?? "";

                        int infoFlag = 1;
                        object infoObj = row["INFORMATION"];
                        if (infoObj != null && infoObj != DBNull.Value)
                            int.TryParse(infoObj.ToString(), out infoFlag);

                        string prefix = infoFlag == 0 ? "Restriction : " : "Information : ";

                        if (paramSb.Length > 0) paramSb.AppendLine();
                        paramSb.Append(prefix).Append(code).Append(" / ").Append(descr).Append(" = ").Append(stmt);
                    }
                }
            }

            // If both result strings are empty, no guideline results
            if (itemSb.Length == 0 && paramSb.Length == 0)
            {
                MessageList("No Guideline Results Returned");
            }

            // Log results (include header and details)
            MessageList("G&R Check Results for Items:" + Environment.NewLine + (itemSb.Length > 0 ? itemSb.ToString() : ""));
            MessageList("G&R Check Results for Parameters:" + Environment.NewLine + (paramSb.Length > 0 ? paramSb.ToString() : ""));
        }
        catch (Exception ex)
        {
            // Log the exception
            MessageList("G&R check exception: " + ex.Message);
        }

        return 1L;
    }
}
Description
This action executes FormulaGuidelineCheck on the current formula object with configured item, technical parameter, and context options (such as selling location, product type, and brand) and then processes the returned DataSet, classifying each result row as either a restriction or information entry based on the information column value, and displays the formatted item-level and parameter-level guideline results as separate output messages.