Generating a unique ID for a view
In some situations you might want to use the
ID attribute for your DOM
elements within a view. However, all DOM IDs must be globally unique. For example, during
collaboration the default highlighting behavior is implemented based on a unique DOM ID. To ensure a
unique ID, you can use the $$viewDOMID$$ placeholder keyword. At run time, this
keyword will be replaced by the view DOM ID.
About this task
$$viewDOMID$$ in your view implementation, you can ensure that all of your DOM
elements have DOM IDs that are globally unique. For example, you might want to highlight an element
such as a button at run time. You can create your element using custom HTML, and assign the DOM ID
attribute by prefixing with $$viewDOMID$$. When the view is rendered, the
$$viewDOMID$$ attribute will be replaced by a unique ID (the DOM ID of the rendered
view) for the element. Note: Stock controls such as Vertical Layout
might shift the scope for the
$$viewDOMID$$ attribute, which can result in
different values for $$viewDOMID$$ in complex views. If you assume that
$$viewDOMID$$ is equal to the context.element.id, you might use an
unexpected value.Procedure
To generate a unique ID:
- Open the view.
- Switch to the Layout page.
- Create a custom HTML view.
- Enter custom HTML code, and use
$$viewDOMID$$in theidattribute:<div id="$$viewDOMID$$_myId1"> <span id="$$viewDOMID$$_myId2"></span> <input id="$$viewDOMID$$_myId3" type="button" class="Jquerybutton" name="jbtnName" value="default"></input> </div>Note: To avoid potential conflicts, use a meaningful suffix after$$viewDOMID$$, for example$$viewDOMID$$_buttonDiv.
Tip: A new alternative method to generate a unique and stable
identification of views uses the
.
controlidpath property in the
context JavaScript API object. This string is stable through most layout changes and can be used as a base to create unique IDs for DOM elements in the implementation of the view. The addition of the controlidpath property is part of the improved coach framework
that enables bots to automate repetitive tasks in IBM® Robotic Process Automation
with Automation Anywhere (IBM RPA). For more
information, see Views. For information about IBM RPA, see the IBM Robotic Process Automation with Automation Anywhere documentation
.
This topic is shared by BAW, CP4BA, CP4BASaaS. Last updated on 2025-03-13 12:15