Quickly remove __c from fields in custom forms

In my personal opinion, I see no value in the __o and __c suffix conventions that overlay/best practice mode have brought to the AR System as it relates to fully custom forms. There are many other areas within Developer Studio and within the Objects themselves at an API level that allow us to know if we are working on unmodified, overlaid or custom objects so making it visible to the administrators by way of the database name is annoying. While __c is important when adding custom fields to forms ‘owned’ by BMC (to avoid possible name collisions in future versions), it doesn’t serve much value on custom forms which is the point behind this utility.

There is an active BMC Communities idea for making this a toggle in dev studio (or possibly out-right removing it) here, please vote if you feel the same way as me:

Now in order to work around this for now in situations where you have many fields you want to strip the __c from (like the example in the idea above with large custom join forms), here is a sample Java API method that will do this for you, simply pass it in the name of the form and it will do it’s magic.

private static void cleanDBNameForFields(String targetForm) {
    // Allow us to work on Custom & Overlay Objects vs Base Objects
    List<Field> fieldsToClean = new ArrayList<Field>();
    try {
        // Get list of all the fields on the targetForm
        List<Fields> fields = ctx.getListFieldObjects(targetForm);
        for (Field field : fields) {
            String fieldName = field.getName();
            // Find field that have __c
            if (fieldName.endsWith("__c")) {
                // Chop off last 3 characters to get rid of __c and then add it to our list of Fields to update
                field.setNewName(fieldName.substring(0, fieldName.length() - 3));
        // Update all the fields in the same transaction
        System.out.println("   " + fieldsToClean.size() + " fields have been cleaned successfully on " + targetForm);
    } catch (ARException e) {

The code is simple enough, we simply get a list of all the fields on the target form, find the ones that have __c at the end, strip it out and then add the updated Field object to a new list of Fields. Once we have our list of fields, we simply feed it to setMultipleFields() so that it commits them all in a single transaction like Developer Studio does when you make changes to forms. This method is very fast, on my system, a join form with ~720 fields that contained __c took only 1.5 seconds to ‘clean’.

I’ve attached below a full program that can be run from the command line and it’s source that makes use of the example above, just feed it your connection info on the command line as well as the target form and it will give you back hours in your day 🙂

Here is a sample run with results shown:




CleanFieldDBNames - Source 5.96 KB 352 downloads


CleanFieldDBNames - Utility 7.34 MB 394 downloads


    4 thoughts on “Quickly remove __c from fields in custom forms

    1. Hi Curtis,

      Your code actually doesn’t manage the names of the views.

      Adding this code will do the job. 🙂

      // Manage Views
      System.out.println(“Cleaning Views on ” + targetForm);
      List viewids = ctx.getListView(targetForm, 0);
      Integer numViewsCleaned = 0;
      for (Integer viewid : viewids) {
      View viewObject = ctx.getView(targetForm, viewid);
      String viewName = viewObject.getName();
      // Find field that have __c
      if (viewName.endsWith(“__c”)) {
      // Chop off last 3 characters to get rid of __c and then add it to our list of Fields to update
      System.out.println(” Cleaning __c for View ” + viewName);
      viewName = viewName.substring(0, viewName.length() – 3);
      if (numViewsCleaned > 0) {
      System.out.println(” ” + numViewsCleaned + ” views have been cleaned on ” + targetForm);
      else {
      System.out.println(” No view to clean on ” + targetForm);


    2. I just used this and it’s great… it doesn’t work for 9.1 though and BMC is still adding the _c. Thanks!

      1. They did change a bit how overlays work in general in 9.1 preempting some newer overlay stuff coming, didn’t think it would have broke this since the APIs haven’t changed but I can take a look at refreshing this utility if it would be useful to you for 9.1

    Leave a Reply

    Your email address will not be published. Required fields are marked *