XPages Tip: Get an element’s id outside XPages events with CSJS

I was facing a problem today where I tried to set a value and do a partial refresh within a client script block on my XPage. Since this script block is outside any XPage event, I could not use the following SSJS within my CSJS to get the IDs of the elements I want to set and refresh:


I googled a bit but was not able to find a solution for this problem. There are many hints but you need to bring them together to get the result. Here is the code that finally worked for me:

var idOfElementToSetValueTo= “;
var idOfElementToCallPartialRefreshOn= “;
dojo.query(„[id$=\\:elementID]“).forEach(function(node, index, arr){
                         idOfElementToSetValueTo = node.id;                           
dojo.query(„[id$=\\:refreshID]“).forEach(function(node, index, arr){
                    idOfElementToCallPartialRefreshOn= node.id;                           


The only downside is that if there are more components on the page all ending with the same „:id“, the function provided will only return the last element. You might want to extend the function to suit your needs then.

Hope this helps!

Meet me at #ls12 @OpenNTF’s booth 516

In a couple of days there will be a bright yellow spot again in Orlando and the rest of the world turns grey due to lack of color.  I am so happy that I can be yellow this year!

I want to thank Niklas Heidloff and Bruce Elgort who gave me the chance to join their team this year and represent OpenNTF at Lotusphere.You have to save a spot on your schedule this year to visit the Product Showcase. Mark booth 516 on your map! Come by and learn all about OpenNTF. Anything you ever wanted to know about OpenNTF? Fire your question at us, we’ll be more than glad to help. Have you ever wondered

  • who or what OpenNTF is?
  • who steers OpenNTF?
  • who funds OpenNTF?
  • how you can join in to enrich the community?
  • how to submit your project to OpenNTF?
  • how to get in contact with OpenNTF?
  • which licenses are available to open source your project?

If you do not have any questions but want to meet great people for a quick chat, you are also very welcome.

Personal note: This is to everyone out there who I had not met in person yet: Come to booth 516 and say Hello! I know so many people from all those social networks which I haven’t actually seen in my life yet. If I don’t say Hi on an occasion outside the Product Showcase I’d like you to say Hi at booth 516.

Catch you around!