VMware Cloud Community
GMCON
Enthusiast
Enthusiast
Jump to solution

JS code to strip off Users Domain name

I am sure this is easy but have not been able to find what I need.  Have not gotten deeply into JavaScript and I need to find a way to take the owner attribute from vRA strip off the domain portion and just feed the username portion in.  Here is what I have, I pull in al information on the system from vRA and map the ones I need so for the owner I have the scripting mapped to the attribute like this

user = vCACVmProperties.get('__Legacy.Workflow.User');

Then I use the user property for an email content that sends it to Servicenow to create a ticket, as we do not have servicenow completely integrated.  The problem is the domain portions are different so what I need to do is strip off the domain portion so that it only feeds the username so instead of username@domain.com it only feeds username.  So I either need to take that user mapping that takes in the username and use it to script something to give the output of only username so I can feed that into the email instead.  Any help explaining would be greatly appreciated.

0 Kudos
1 Solution

Accepted Solutions
Burke-
VMware Employee
VMware Employee
Jump to solution

if user =

username@domain.com

then the following should work for you:

var username = user.split("@")[0];

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you!

Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator
for vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter

View solution in original post

0 Kudos
2 Replies
Burke-
VMware Employee
VMware Employee
Jump to solution

if user =

username@domain.com

then the following should work for you:

var username = user.split("@")[0];

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you!

Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator
for vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter
0 Kudos
GMCON
Enthusiast
Enthusiast
Jump to solution

That worked perfectly thank you very much.

0 Kudos