Following is the standard convention to note while creating new fields in Hawksearch:
Only alphanumeric characters and the underscore are allowed in the fieldname
All characters are lowercase
Spaces must be replaced by underscores '_'
Underscore cannot be at the beginning or end of the name
Atleast one character is required
Atleast one number is required - an ānā will be appended to it
C# code block for your reference as below:
public static string GetStandardFieldName(string InputField) { var rgx = new System.Text.RegularExpressions.Regex("[^a-zA-Z0-9_]"); string SField = InputField; SField = SField.Replace(" ", "_"); SField = rgx.Replace(SField, ""); if (!string.IsNullOrEmpty(SField)) { SField = SField.ToLower(); if (SField.StartsWith("_")) SField = SField.Remove(0, 1); if (SField.EndsWith("_")) SField = SField.Remove(SField.Length - 1); } if (!string.IsNullOrEmpty(SField)) { if(int.TryParse(SField.Substring(0, 1), out int result)) SField= "n" + SField; } return SField; }
Examples:
GetStandardFieldName("Hello, world!") GetStandardFieldName("99Hello, world!") GetStandardFieldName("_1Hello, world!_")
Outputs:
hello_world
n99hello_world
n1hello_world