I suggest you add "async: false" attribute to GetPersonalSiteHostUrl function, otherwise _PersonalSiteHostUrl will be " " when executed.
And when I use _PersonalSiteHostUrl = data.d.PersonalSiteHostUrl
, the code report error ,I change it to _PersonalSiteHostUrl = data.d.PersonalUrl
.
No matter which one you use, the Url ends with “/”,
you should modify the part of the code you used to splice the URL.
var raJsEnableOrDisableUrl = _PersonalSiteHostUrl + "_api/web/lists/getbytitle('PS Configuration')/items?$select=sp_Value&$filter=Title eq 'PS_OD_VERIFY_USER_STATUS'";
var raJsSCAdminsUrl = _PersonalSiteHostUrl + "_api/web/lists/getbytitle('PS Configuration')/items?$select=sp_Value&$filter=Title eq 'PS_SC_Admins'";
After I made the above changes to the code and created the corresponding list, it ran successfully.
Full code for your reference:45102-code.txt
You could use developer tool to debug the code, then you will understand the code running sequence and potential errors, which can help you write better code.
Debug JavaScript in Chrome
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.