Code: Select all
public static class CustomFunctions
{
public static string? GetValueByKey(StiBusinessObject businessObject, string key)
{
businessObject.Connect();
try
{
if (businessObject.BusinessObjectValue is not IDictionary<string, string> dictionary) return null;
return dictionary.TryGetValue(key, out var value) ? value : null;
}
finally
{
businessObject.Disconnect();
}
}
public static void Register()
{
StiFunctions.AddFunction(
category: "HELPERS",
functionName: nameof(CustomFunctions.GetValueByKey),
description: "Returns value by key from dictionary.",
typeOfFunction: typeof(CustomFunctions),
returnType: typeof(string),
returnDescription: "The matching value or null",
argumentTypes: [typeof(StiBusinessObject), typeof(string)],
argumentNames: ["Dictionary", "Key"]);
}
}
Is there a way to do this?