SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

For example:

I have a site under this url:

When I open it i would like to read it's GUID for future use in my custom AssetPortalBrowser.aspx url picker.


share|improve this question
up vote 6 down vote accepted

Use get_id to get the GUID

var value = SP.Web.get_id();

Example usage:

<script type="text/javascript">  
ExecuteOrDelayUntilScriptLoaded(getSite, "sp.js");  
var context = null;  
var web = null;  
    function getSite() {  
        context = new SP.ClientContext.get_current();  
        web = context.get_web();  
        context.executeQueryAsync(Function.createDelegate(this, this.onSuccessMethod), Function.createDelegate(this, this.onFailureMethod));  
    function onSuccessMethod(sender, args) {  
        alert('your are there :' + web.get_title() + '\n ID:' + web.get_id());  
    function onFaiureMethodl(sender, args) {  
        alert('you suck ' + args.get_message() + '\n' + args.get_stackTrace());  
share|improve this answer
Thanks man it works great! – Daniel Badanjak Jan 8 '13 at 21:27
My pleasure. Happy SharePointing :) – Falak Mahmood Jan 8 '13 at 21:28

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.