5

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!

0

1 Answer 1

8

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>  
1
  • My pleasure. Happy SharePointing :) Commented Jan 8, 2013 at 21:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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