Jahia in English > Updating user properties...

0 (0 Good)
0 (0 Bad)

Updating user properties programatically

by  namitgupta »  2012/12/11 15:29

Hi All,

We have a requirement, wherein, we need to update j:Organization field of the user node in jahia. We have around 1000 users in JCR.

We are looking at programmatic ways to achieve this.

Please share your thoughts on this.

 

Regards,

Namit Gupta.

  (namitgupta)

Number of messages  36
Registration date
0 (0 Good)
0 (0 Bad)

Re: Updating user properties programatically

by  glucazeau »  2012/12/17 14:06

Hello,

there are many ways to achieve this but one could be the following:

retrieve the path for each user using a JCR query like this: SELECT * FROM [jnt:user]. What you need here is the "Path" value, so maybe calling it from a JSP you could format the results and get just the paths.

Then you can quickly generate the following line for each user and execute it in the JCR Console (tools/jcrConsole.jsp)

session.getNode("/users/<path>/<to>/<the>/<user>").setProperty("j:Organization","Your company");

Add "session.save()" at the end (you can first run your commands without it to check that there is no syntax error for example). I also know there is a size limitation for the number of instructions you can run in this console so maybe you'll have to split them.

Regards,

Guillaume

  • Re: Updating user properties programatically
    2012/12/17 14:06

    glucazeau <p> Hello,</p> <p> there are many ways to achieve this but one could be the following:</p> <p> retrieve the path for each user using a JCR query like this: SELECT * FROM [jnt:user]. What you need here is the &quot;Path&quot; value, so maybe calling it from a JSP you could format the results and get just the paths.</p> <p> Then you can quickly generate the following line for each user and execute it in the JCR Console (tools/jcrConsole.jsp)</p> <p> session.getNode(&quot;/users/&lt;path&gt;/&lt;to&gt;/&lt;the&gt;/&lt;user&gt;&quot;).setProperty(&quot;j:Organization&quot;,&quot;Your company&quot;);</p> <p> Add &quot;session.save()&quot; at the end (you can first run your commands without it to check that there is no syntax error for example). I also know there is a size limitation for the number of instructions you can run in this console so maybe you&#39;ll have to split them.</p> <p> Regards,</p> <p> Guillaume</p>

  • Number of messages  95
    Registration date Dec 17, 2012
    Contact
    Share
    Feedback

    Get in touch

    Whether you are a current user or if you are just evaluating Jahia, we are here to help.

    Contact us

    Share this page