VMware Cloud Community
Paragbhardwaj19
Enthusiast
Enthusiast
Jump to solution

Get the Owner Email Address

Hi All,

I have VRA 7.2 and want to enable custom email from VRO. Can someone please let me know the payload definition that i can get the VM owner email address. I am able to get the IP,VM name and resources but not able to get the email address.

Thanks

Parag 

1 Solution

Accepted Solutions
sbeaver
Leadership
Leadership
Jump to solution

Here is the code that I am using to get the email address for the person that the workflow is requested_for

/*

  - Retrieve the email address of a user principal

  - Input: vCACCAFEHost [vCACCAFE:vCACHost]

  - Input: principalId [String]

  - Output: emailAddress [String]

*/

var emails = new Array();

var principalId = System.getContext().getParameter("__asd_requestedFor");

var vCACCAFEHost = Server.findAllForType("vCACCAFE:vCACHost")[0]

var tenant = vCACCAFEHost.tenant;

var authenticationClient = vCACCAFEHost.createAuthenticationClient();

var authenticationPrincipalService = authenticationClient.getAuthenticationPrincipalService();

try {

               var principal = authenticationPrincipalService.getPrincipal(tenant,principalId);

             

               //Principal is a vCACCAFEUser object

               var emailAddress = principal.getEmailAddress();

               return emailAddress

             

} catch (e) {

               var emailAddress = "Could not find email";

               return emailAddress

}

Steve Beaver
VMware Communities User Moderator
VMware vExpert 2009 - 2020
VMware NSX vExpert - 2019 - 2020
====
Co-Author of "VMware ESX Essentials in the Virtual Data Center"
(ISBN:1420070274) from Auerbach
Come check out my blog: [www.virtualizationpractice.com/blog|http://www.virtualizationpractice.com/blog/]
Come follow me on twitter http://www.twitter.com/sbeaver

**The Cloud is a journey, not a project.**

View solution in original post

4 Replies
daphnissov
Immortal
Immortal
Jump to solution

The email address isn't a property that's passed. The owner or requester is, and that property is __asd_requestedBy.

Reply
0 Kudos
Paragbhardwaj19
Enthusiast
Enthusiast
Jump to solution

any idea which custom property will help me on VirtualMachine.Admin.AdministratorEmail on my VRA. Also Thanks for my other issue.

Thanks

parag

Reply
0 Kudos
sbeaver
Leadership
Leadership
Jump to solution

Here is the code that I am using to get the email address for the person that the workflow is requested_for

/*

  - Retrieve the email address of a user principal

  - Input: vCACCAFEHost [vCACCAFE:vCACHost]

  - Input: principalId [String]

  - Output: emailAddress [String]

*/

var emails = new Array();

var principalId = System.getContext().getParameter("__asd_requestedFor");

var vCACCAFEHost = Server.findAllForType("vCACCAFE:vCACHost")[0]

var tenant = vCACCAFEHost.tenant;

var authenticationClient = vCACCAFEHost.createAuthenticationClient();

var authenticationPrincipalService = authenticationClient.getAuthenticationPrincipalService();

try {

               var principal = authenticationPrincipalService.getPrincipal(tenant,principalId);

             

               //Principal is a vCACCAFEUser object

               var emailAddress = principal.getEmailAddress();

               return emailAddress

             

} catch (e) {

               var emailAddress = "Could not find email";

               return emailAddress

}

Steve Beaver
VMware Communities User Moderator
VMware vExpert 2009 - 2020
VMware NSX vExpert - 2019 - 2020
====
Co-Author of "VMware ESX Essentials in the Virtual Data Center"
(ISBN:1420070274) from Auerbach
Come check out my blog: [www.virtualizationpractice.com/blog|http://www.virtualizationpractice.com/blog/]
Come follow me on twitter http://www.twitter.com/sbeaver

**The Cloud is a journey, not a project.**
Paragbhardwaj19
Enthusiast
Enthusiast
Jump to solution

Thanks sbeaver, it works

Reply
0 Kudos