Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Created February 8, 2024 15:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjoerntx/bbcb706083f3ef61ada2306d2f3400d5 to your computer and use it in GitHub Desktop.
Save bjoerntx/bbcb706083f3ef61ada2306d2f3400d5 to your computer and use it in GitHub Desktop.
private static void RenameMergeFields(ApplicationFieldCollection applicationFields,
string oldColumnName,
string newColumnName)
{
// iterate through all ApplicationFields
foreach (ApplicationField applicationField in applicationFields)
{
// check if the ApplicationField is a merge field and contains the old column name
if (applicationField.TypeName == "MERGEFIELD" &&
applicationField.Name.Contains(oldColumnName))
{
// create a new MergeField object and replace the old column name with the new column name
MergeField mergeField = new MergeField(applicationField);
mergeField.Name = mergeField.Name.Replace(oldColumnName, newColumnName);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment