Search This Blog

Wednesday, November 11, 2020

SPFx get current url and current user and load master data

     pnp.sp.site.getWebUrlFromPageUrl(window.location.href)

      .then(res => {
        this.absoluteUrl = res;
        pnp.sp.web.currentUser.get().then(result => {
          this.CurntUserId = result.Id;
          this.CurntUserEmail = result.Email;
          this.CurntUserTitle = result.Title;
          this.SubmittedBy = result.Title;
          //inital querter
          this.MonthTitle = this.getQuarter(new Date()).toString();
          this.MonthNumber = this.getQuarter(new Date()).toString();
          //bind master data
          this.LoadAllMasterData();
          var queryReqId = new UrlQueryParameterCollection(window.location.href);
          if (queryReqId != null && queryReqId != undefined) {
            if (queryReqId.getValue("ReqId") != undefined) {
              this.loadDataLS(queryReqId.getValue("ReqId"));
            }
            else {
              this.getUniqueNumber();
            }
          }

        });
      });

No comments:

Post a Comment