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);
}
);
Solved! Go to Solution.
You have to use portal queryGroups as PortalGroup does not have a constructor method.
Don't forget to mark this thread as answered
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."
Jose,
No portal.getPortalUser() is a method not a constructor that would use new.
Thank you Robert,
I just found this post that also helps:
https://community.esri.com/message/606421?q=portal%20getPortalUser
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.
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.
Jose,
Then it is not recognizing you as being signed in. You need to do
portal.signIn().then(function() {
var portalUser = portal.getPortalUser();
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;
});
.....
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?
It works thnak you!