How to get the runtime id of a web block

Hi All,

Is is it possible to get the id of a web block and save it to a database ?

I have web block which name Template_Static_TSE_V1 and I want it to save in database. I have the following error when I tried to assign the runtime id. Please see screen shot below :

Thanks for advance in any help and suggestion.

Hello Ariel,

I don't think what you're trying to do makes sense, or is possible.

What are you trying to achieve doing that?


Hi Eduardo,

Thanks for the reply. I have a button inside the web block and when I click it, I want to get the id of the web block and save it to database. We have four web block and each web block has it's own effectivity date. For example web block B has effectivity date of May 15, 2018 and web block C has effectivity date of May 20, 2018. Currently the system use web block A, when web block B reach it effectivity date, then the system will set web block A to be inactive and web block B will be active (will be used by the system) and so on. I need to get the id of the current web block so I can set it to be inactive later on.

Hello Ariel,

This will not work.
The ID of an interface element is dynamic generated when the page is build on request.

See the problem?

I would use an Static Entity to identify the Web Blocks (each record represents a web block) and than, in an entity, would add the records with an Id to the static entity and the limit date, and than in the page that uses the web block, fetch the web block to show and use IF's to show the correct one.

Well, in fact, I wouldn't do this this way, but as I don't know your requirements or why you choose this approach of web blocks used in different periods of time, I can't provide a better alternative.


Now that I read your question more carefully, I think you are misunderstanding completely that is a web block...
A web block is justa a "template" for a piece of Interface. It does not "exists". When the page is built on request, the server see if the page have any Web Block and uses it to build the page.

You can't "access" a web block from browser, for example. 


Let me change my question, can we pass the id of an element for example an input (textbox) to a local variable, if Yes can we do that also on a web block because weblock has it own ID. But if no I think I will try the static approach. 

Hi Ariel.

You can. But it's useless, as in the next time your page is rendered, its Id can be different. Even when you Ajax refresh an element (web block included), Its Id changes.


Hi Ariel,

Just to reiterate what Eduardo said, a Web Block does not have an Id. A Web Block is not rendered as an HTML element. So your statement "because [a] webblock has it[s] own ID" is false.

Just as an example, I have a simple page containing a single Web Block:

The Web Block just contains some text:

When the page is rendering, this is the resulting page:

And this is the HTML:

As you can see, the text in the Web Block is just rendered as-is, there's nothing containing it, there's no ID!

Also, again reiterating what Eduardo said, the IDs of screen elements that actually do have an HTML representation are generated dynamically, so they may change between page loads, may be different for different users, and may change with each change to the page. So IDs are pretty useless* when it comes to identifying screen elements over sessions.

*Note that the way that Widget IDs are currently generated, they always include the Name Property of the Widget, so you could theoretically use that. This is not guarenteed to be always the case however, so I wouldn't rely on it.