Select to view content in your preferred language

Where does the parameter "portalUser" come from?

3717
20
Jump to solution
03-21-2017 10:43 AM
JoseSanchez
Frequent Contributor

Hello everyone,

I do not understand very well the notation for this function:    function (portalUser){

The parameter "portalUser" where is it populated and declared?

Is there any online converted that changes from AMD to other structure easier to read?

This function is used in this sample: https://developers.arcgis.com/javascript/3/jssamples/portal_oauth_inline.html

Thanks

function displayItems(){
     
new arcgisPortal.Portal(info.portalUrl).signIn().then(
       
function (portalUser){
          console
.log("Signed in to the portal: ", portalUser);

          domAttr
.set("userId", "innerHTML", portalUser.fullName);
          domStyle
.set("anonymousPanel", "display", "none");
          domStyle
.set("personalizedPanel", "display", "block");

          queryPortal
(portalUser);
       
}
     
).otherwise(
       
function (error){
          console
.log("Error occurred while signing in: ", error);
       
}
     
);

0 Kudos
20 Replies
RobertScheitlin__GISP
MVP Emeritus

You have to use portal queryGroups as PortalGroup does not have a constructor method.

Don't forget to mark this thread as answered

0 Kudos
JoseSanchez
Frequent Contributor

Hi Robert,

I wrote this code:

var portal = new arcgisPortal.Portal('http://[my organization].maps.arcgis.com');

var portalUser = new portal.getPortalUser();

var myArray = portalUser.getGroups;

Is that correct to declare portalUser = new portal.getPortalUser();

Debugging the program I get the message "myArray is Undefined."  

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Jose,

   No portal.getPortalUser() is a method not a constructor that would use new.

0 Kudos
JoseSanchez
Frequent Contributor

Thank you Robert,

I just found this post that also helps:

https://community.esri.com/message/606421?q=portal%20getPortalUser

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Jose,

  Glad you got it.

Don't forget to mark this question as answered by clicking on the "Correct Answer" link on the reply that answered your question.

0 Kudos
JoseSanchez
Frequent Contributor

Hi Robert,

I am getting the error message below:

var portal = new arcgisPortal.Portal('http://[my organization].maps.arcgis.com');

             

var portalUser = portal.getPortalUser();

             

Error message in debugging mode:  variable portalUser is undefined.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Jose,

  Then it is not recognizing you as being signed in. You need to do

portal.signIn().then(function() {
  var portalUser = portal.getPortalUser();
0 Kudos
JoseSanchez
Frequent Contributor

Robert,

Is this correct?

In debugging mode it does not go inside portal.signIn() , so it does not executes the function:

             var portal = new arcgisPortal.Portal('http://[my organitation].maps.arcgis.com');

              portal.signIn().then(function() {
                  var portalUser = portal.getPortalUser();
                  console.log("Signed in to the portal: ", portalUser);
                  console.log(portalUser.fullName);
                  var myArray = null;

                  var myArray = portalUser.getGroups;

              });

            .....

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Jose,

   It looks fine to me except that the signIn method returns a potalUser as the deferred result:

var portal = new arcgisPortal.Portal('http://[my organitation].maps.arcgis.com');
portal.signIn().then(function (loggedInUser){‍‍‍
  console.log("Signed in to the portal: ", loggedInUser‍‍‍);
  console.log(loggedInUser‍‍‍.fullName);
  var myArray = null;
  var myArray = loggedInUser‍‍‍.getGroups;
});

Are you adding a break point inside the then portion?

JoseSanchez
Frequent Contributor

It works thnak you!

0 Kudos