Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

For example:

I have a site under this url: http://intranet.contoso.com/news

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

Thanks!

share|improve this question
add comment

1 Answer

up vote 5 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.load(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());  
    }  
</script>  
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
add comment

Your Answer

 
discard

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.