I am trying to dynamically set the Project UID in an Angular app which is deployed to every subsite throughout my PWA. I need to be able to ideally, store the Project UID in a global variable which I can then use throughout the rest of the app to point to the correct REST api endpoint.
I'm struggling with how I can leverage the function for getting the current site's Project UID which I found here [https://sharepoint.stackexchange.com/questions/224485/project-web-app-get-project-id-from-project-related-site-via-rest], to update the global variable with the Project UID to use in my app controllers. The function works, supposedly, but when I console.log(ProjectUID) I don't get the GUID I'm expecting, instead I get a boolean 'false'.
Any suggestions?
var ProjectUID = ExecuteOrDelayUntilScriptLoaded(getProjectUIDProperty, "sp.js"); function getProjectUIDProperty() { var ctx = new SP.ClientContext.get_current(); console.log(ctx); this.web = ctx.get_web(); console.log(this.web); this.props = this.web.get_allProperties(); ctx.load(this.web); ctx.load(this.props); ctx.executeQueryAsync(Function.createDelegate(this, gotProperty), Function.createDelegate(this, failedGettingProperty)); } function gotProperty() { let ProjectUID = this.props.get_item('MSPWAPROJUID'); } function failedGettingProperty() { alert('Error: ' + args.get_message()); } console.log(ProjectUID); [1]: https://sharepoint.stackexchange.com/questions/224485/project-web-app-get-project-id-from-project-related-site-via-rest