Legacy Knowledge Base
Published Sep. 10, 2025

What is the 'instance-id' field?

Written By

Jose L. Bango

How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!

While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.

Legacy Article

You are viewing an article from our legacy "FastTrack" publication program, made available for informational purposes. Articles in this program were published without a requirement for independent editing or verification and are provided"as is" without guarantee.

Before using any information from this article, independently verify its suitability for your situation and project.

Issue

  • What is the instace-id or instanceId field and what is it used for?

Environment

  • All Liferay versions

Resolution

  • It's a random alphanumeric value.
  • Liferay uses this value to be able to identify the field uniquely.
  • Actual generation sample code:
    • JS (fieldSupport.js)
      export function generateInstanceId(isNumbersOnly) {
      return Math.random()
      .toString(isNumbersOnly ? 10 : 36)
      .substr(2, 8);
      }
    • Java (StringUtil.randomString() method is used)
      public static String randomString(int length) {
      Random random = new Random();

      char[] chars = new char[length];

      for (int i = 0; i < length; i++) {
      int index = random.nextInt(_RANDOM_STRING_CHAR_TABLE.length);

      chars[i] = _RANDOM_STRING_CHAR_TABLE[index];
      }

      return new String(chars);
      }

Additional Information

  • Sometimes it is used to generate the field ID, which must also be unique. As per the W3C DOM#getElementById()
    • If more than one element has an ID attribute with that value, what is returned is undefined.
Did this article resolve your issue ?

Legacy Knowledge Base