Sunday, 15 January 2012

Creating SharePoint Site with JavaScript -



Creating SharePoint Site with JavaScript -

i attempting utilize jsom create sub-site (web) on button-click. function working - in far site created given configuration. however, despite fact site indeed beingness create, executequeryasync phone call always routes failure function. relevant code below:

var ctx = sp.clientcontext.get_current(); var web = ctx.get_web(); var webcreationinfo = new sp.webcreationinformation(); webcreationinfo.set_title(portalname); //note: variable defined elsewhere webcreationinfo.set_description(''); webcreationinfo.set_language(1033); webcreationinfo.set_url(weburl); //note: variable defined elsewhere webcreationinfo.set_usesamepermissionsasparentsite(false); webcreationinfo.set_webtemplate(templateguid); //note: variable defined elsewhere web.get_webs().add(webcreationinfo); web.update(); ctx.load(web); ctx.executequeryasync( function() { alert("created site"); }, function(sender, args) { alert('request failed. ' + args.get_message() + '\n' + args.get_stacktrace()); } );

this includes couple variables defined elsewhere in code, should not part of problem. site created, using right template, name, , url.

the 'request failed' alert pops me, despite site beingness created correctly. value of args.get_message() "unexpected response server" , value of args.get_stacktrace() 'null'.

the issue here due button , not above code. needed add together 'event.preventdefault();' start of onclick function. otherwise, page attempts refresh - happens much faster site can provisioned.

javascript sharepoint

No comments:

Post a Comment