06-29-2015 10:51 AM - edited 03-01-2019 06:35 AM
Task Name | Get Submitter User Information |
Description | |
Prerequisites |
|
Category | Workflow |
Components | vSphere 5.x |
User Inputs |
Instructions for Regular Workflow Use:
Many thanks go out to Wee Kuenn Leow.
The Workflow:
The Variables that get updated:
Jun 29, 2015 17:39:54 UTC userId admin
Jun 29, 2015 17:39:54 UTC firstName Orf
Jun 29, 2015 17:39:54 UTC lastName Gelbrich
Jun 29, 2015 17:39:54 UTC groupName null
Jun 29, 2015 17:39:54 UTC UserId=admin, Name=OrfGelbrich
Jun 29, 2015 17:39:59 UTC myEMAIL: ogelbric@cisco.com
Jun 29, 2015 17:39:59 UTC myNAME: OrfGelbrich
Jun 29, 2015 17:39:59 UTC myGROUPNAME: null
Jun 29, 2015 17:39:59 UTC myGROUPNAME01: undefined
Jun 29, 2015 17:39:59 UTC myGROUPID: 0
The Cloupia Script
// Get Submitter Info
importPackage(java.net);
importPackage(java.lang);
importPackage(java.util);
importPackage(java.io);
var userId = ctxt.getUserId();
// Get the current workflow submittes profile
var userProfile = ctxt.getAPI().userAPIGetMyLoginProfile();
var firstName = userProfile.getFirstName();
var lastName = userProfile.getLastName();
var groupName = userProfile.getGroupName();
logger.addInfo("userId "+userId);
logger.addInfo("firstName "+firstName);
logger.addInfo("lastName "+lastName);
logger.addInfo("groupName "+groupName);
if ( groupName != null ) {
var groupName01 = groupName.split("@")[0];
}
var groupId = userProfile.getGroupId();
var role = userProfile.getRole();
var email = userProfile.getEmail();
// Add some debug statements into SR log
logger.addDebug("UserId=" + userId + ", Name=" + firstName + lastName);
// Save into workflow variables as needed
ctxt.updateInput("SUBMITTER_EMAIL", email);
ctxt.updateInput("SUBMITTER_FIRSTNAME", firstName);
ctxt.updateInput("SUBMITTER_LASTNAME", lastName);
ctxt.updateInput("SUBMITTER_GROUPNAME", groupName);
ctxt.updateInput("SUBMITTER_GROUPNAME01", groupName01);
ctxt.updateInput("SUBMITTER_GROUPID", groupId);
// addinfo
logger.addDebug("myEMAIL: " + email);
logger.addDebug("myNAME: " + firstName + lastName);
logger.addDebug("myGROUPNAME: " + groupName);
logger.addDebug("myGROUPNAME01: " + groupName01);
logger.addDebug("myGROUPID: " + groupId);
The Log Run:
Service Request ID: 5260
Workflow Inputs:
- SUBMITTER_EMAIL
- SUBMITTER_FIRSTNAME
- SUBMITTER_LASTNAME
- SUBMITTER_GROUPNAME
- SUBMITTER_GROUPNAME01
- SUBMITTER_GROUPID
Jun 29, 2015 17:39:40 UTC Request submitted
Jun 29, 2015 17:39:45 UTC Executing workflow item number 1
Jun 29, 2015 17:39:45 UTC Completed workflow item number 1, with status Completed
Jun 29, 2015 17:39:51 UTC Executing workflow item number 2
Jun 29, 2015 17:39:51 UTC Trigger context executeWorkFlowStep called
Jun 29, 2015 17:39:51 UTC Executing custom action Get Submitter Information (ExecuteCloupiaScript)
Jun 29, 2015 17:39:51 UTC Executing custom action Get Submitter Information (ExecuteCloupiaScript)
Jun 29, 2015 17:39:54 UTC Executing cloupia script: Get Submitter Info - modified for AD
Jun 29, 2015 17:39:54 UTC userId admin
Jun 29, 2015 17:39:54 UTC firstName Orf
Jun 29, 2015 17:39:54 UTC lastName Gelbrich
Jun 29, 2015 17:39:54 UTC groupName null
Jun 29, 2015 17:39:54 UTC UserId=admin, Name=OrfGelbrich
Jun 29, 2015 17:39:59 UTC myEMAIL: ogelbric@cisco.com
Jun 29, 2015 17:39:59 UTC myNAME: OrfGelbrich
Jun 29, 2015 17:39:59 UTC myGROUPNAME: null
Jun 29, 2015 17:39:59 UTC myGROUPNAME01: undefined
Jun 29, 2015 17:39:59 UTC myGROUPID: 0
Jun 29, 2015 17:39:59 UTC Completed cloupia script Get Submitter Info - modified for AD
Jun 29, 2015 17:39:59 UTC Task #1 (Get Submitter Information (ExecuteCloupiaScript)) completed successfully in 7 seconds
Jun 29, 2015 17:39:59 UTC Input/Output values for Task #1 (Get Submitter Information (ExecuteCloupiaScript)):
Jun 29, 2015 17:39:59 UTC [Local Input: Label = Get Submitter Info - modified for AD]
Jun 29, 2015 17:39:59 UTC [Local Input: Script = // Get Submitter Info importPackage(java.net); importPackage(java.lang); importPackage(java.util); importPackage(java.io); var userId = ctxt.getUserId(); // Get the current workflow submittes profile var userProfile = ctxt.getAPI().userAPIGetMyLoginProfile(); var firstName = userProfile.getFirstName(); var lastName = userProfile.getLastName(); var groupName = userProfile.getGroupName(); logger.addInfo('userId '+userId); logger.addInfo('firstName '+firstName); logger.addInfo('lastName '+lastName); logger.addInfo('groupName '+groupName); if ( groupName != null ) { var groupName01 = groupName.split('@')[0]; } var groupId = userProfile.getGroupId(); var role = userProfile.getRole(); var email = userProfile.getEmail(); // Add some debug statements into SR log logger.addDebug('UserId=' + userId + ', Name=' + firstName + lastName); // Save into workflow variables as needed ctxt.updateInput('SUBMITTER_EMAIL', email); ctxt.updateInput('SUBMITTER_FIRSTNAME', firstName); ctxt.updateInput('S
Jun 29, 2015 17:39:59 UTC [Local Input: Undo Script = ]
Jun 29, 2015 17:39:59 UTC Completed workflow item number 2, with status Completed
Jun 29, 2015 17:40:00 UTC Executing workflow item number 3
Jun 29, 2015 17:40:00 UTC Completed workflow item number 3, with status Completed
Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: