08-31-2016 07:58 AM - edited 03-01-2019 06:43 AM
Task Name | Example on how to retrieve LOV values and use them in a switching logic |
Description | |
Prerequisites |
|
Category | Workflow |
Components | vSphere 5.x |
User Inputs | e-mail address |
Output | e-mail with counter |
Instructions for Regular Workflow Use:
This LOV retrieval does two things:
1) it retrieves all values of the LOV and returns a comma separated list.
2) it can retrieve a single entry out of the LOV entries.
The workflow:
The LOV that is being retrieved:
The LOV values:
Workflow Run:
In the log it found it:
The loop is going though all entries:
1st LOV entry is left:
2nd LOV entry is right:
3rd LOV entry is center:
The custom task code:
mportPackage(com.cloupia.service.cIM.inframgr.customactions);
importPackage(java.util);
importPackage(java.lang);
var lovName = input.LOV_Name;
var lovEntryFind = input.LOV_Entry_Find;
logger.addInfo("Looking for LOV entry: "+lovEntryFind);
logger.addInfo("LOV input name1: "+lovName);
lovName = "custom_provider_"+lovName;
logger.addInfo("LOV input name2: "+lovName);
//var listOfCustomLOV = CustomActionUtil.getWFCustomLovPairs("custom_provider_vmtags");
var listOfCustomLOV = CustomActionUtil.getWFCustomLovPairs(lovName);
var a="";
var b="";
//
//Loop though all lines except the last one
//
for(var count = 0;count<listOfCustomLOV.size()-1;count++) {
logger.addInfo(listOfCustomLOV.get(count).getLovLabel()+":"+listOfCustomLOV.get(count).getLovValue());
if (listOfCustomLOV.get(count).getLovLabel() == lovEntryFind) {
logger.addInfo("Found the entry returning this: "+listOfCustomLOV.get(count).getLovValue());
b=listOfCustomLOV.get(count).getLovValue();
}
a=a+listOfCustomLOV.get(count).getLovValue()+",";
}
The workflow run log:
Service Request ID: 7930
Workflow Inputs:
- LOVselector
- LOOPvar
Aug 31, 2016 14:44:23 UTC Request submitted
Aug 31, 2016 14:44:24 UTC Executing workflow item number 1
Aug 31, 2016 14:44:24 UTC Completed workflow item number 1, with status Completed
Aug 31, 2016 14:44:28 UTC Executing workflow item number 2
Aug 31, 2016 14:44:28 UTC Trigger context executeWorkFlowStep called
Aug 31, 2016 14:44:28 UTC Executing custom action Retrive_LOV_Values_v1 (custom_Retrieve_LOV_Values)
Aug 31, 2016 14:44:28 UTC Executing custom action Retrive_LOV_Values_v1 (custom_Retrieve_LOV_Values)
Aug 31, 2016 14:44:28 UTC Executing custom script for Retrieve_LOV_Values
Aug 31, 2016 14:44:31 UTC Looking for LOV entry: center
Aug 31, 2016 14:44:31 UTC LOV input name1: K1
Aug 31, 2016 14:44:31 UTC LOV input name2: custom_provider_K1
Aug 31, 2016 14:44:31 UTC left:left
Aug 31, 2016 14:44:31 UTC right:right
Aug 31, 2016 14:44:31 UTC LOV output list: left,right,center
Aug 31, 2016 14:44:31 UTC Count: 3
Aug 31, 2016 14:44:31 UTC Found the entry returning this: center
Aug 31, 2016 14:44:31 UTC Processing output: LOV_Value
Aug 31, 2016 14:44:32 UTC Processing output: LOV_Found_Entry_Value
Aug 31, 2016 14:44:33 UTC Task #2 (Retrive_LOV_Values_v1 (custom_Retrieve_LOV_Values)) completed successfully in 5 seconds
Aug 31, 2016 14:44:33 UTC Input/Output values for Task #2 (Retrive_LOV_Values_v1 (custom_Retrieve_LOV_Values)):
Aug 31, 2016 14:44:33 UTC [Local Input: LOV_Name = K1]
Aug 31, 2016 14:44:33 UTC [Mapped Input: LOV_Entry_Find = center]
Aug 31, 2016 14:44:33 UTC [Output: LOV_Value = left,right,center]
Aug 31, 2016 14:44:33 UTC [Output: LOV_Found_Entry_Value = center]
Aug 31, 2016 14:44:33 UTC Completed workflow item number 2, with status Completed
Aug 31, 2016 14:44:38 UTC Executing workflow item number 3
Aug 31, 2016 14:44:38 UTC Trigger context executeWorkFlowStep called
Aug 31, 2016 14:44:38 UTC Executing custom action Retrive_LOV_Values_v1 (Start Loop)
Aug 31, 2016 14:44:38 UTC Executing custom action Retrive_LOV_Values_v1 (Start Loop)
Aug 31, 2016 14:44:41 UTC Start While task execution iteration no - 1
Aug 31, 2016 14:44:44 UTC Task #3 (Retrive_LOV_Values_v1 (Start Loop)) completed successfully in 6 seconds
Aug 31, 2016 14:44:44 UTC Input/Output values for Task #3 (Retrive_LOV_Values_v1 (Start Loop)):
Aug 31, 2016 14:44:44 UTC [Local Input: List based iteration = true]
Aug 31, 2016 14:44:44 UTC [Mapped Input: Input for list based iteration = left,right,center]
Aug 31, 2016 14:44:44 UTC [Local Input: User Input to assign iterated values = input_1_LOOPvar780]
Aug 31, 2016 14:44:44 UTC [Local Input: Count based iteration = false]
Aug 31, 2016 14:44:44 UTC [Local Input: Number of times to loop = ]
Aug 31, 2016 14:44:44 UTC [Output: START_LOOP_OUTPUT = left]
Aug 31, 2016 14:44:44 UTC Completed workflow item number 3, with status Completed
Aug 31, 2016 14:44:44 UTC Executing workflow item number 4
Aug 31, 2016 14:44:44 UTC Trigger context executeWorkFlowStep called
Aug 31, 2016 14:44:44 UTC Executing custom action Retrive_LOV_Values_v1 (If Else)
Aug 31, 2016 14:44:44 UTC Executing custom action Retrive_LOV_Values_v1 (If Else)
Aug 31, 2016 14:44:47 UTC Condition evaluated to True; subsequent Task is Wait for Duration
Aug 31, 2016 14:44:47 UTC Re-evaluting the flow to execute next task based on the condition providedIfElse_12043
Aug 31, 2016 14:44:47 UTC Completed workflow item number 4, with status Completed
Aug 31, 2016 14:44:52 UTC Executing workflow item number 5
Aug 31, 2016 14:44:52 UTC Trigger context executeWorkFlowStep called
Aug 31, 2016 14:44:52 UTC Executing custom action Retrive_LOV_Values_v1 (Wait for Duration)
Aug 31, 2016 14:44:52 UTC Executing custom action Retrive_LOV_Values_v1 (Wait for Duration)
Aug 31, 2016 14:44:55 UTC Waiting 10 seconds
Aug 31, 2016 14:45:05 UTC Completed waiting 10 seconds
Aug 31, 2016 14:45:05 UTC Task #5 (Retrive_LOV_Values_v1 (Wait for Duration)) completed successfully in 13 seconds
Aug 31, 2016 14:45:05 UTC Input/Output values for Task #5 (Retrive_LOV_Values_v1 (Wait for Duration)):
Aug 31, 2016 14:45:05 UTC [Local Input: Duration = 10]
Aug 31, 2016 14:45:05 UTC Completed workflow item number 5, with status Completed
Aug 31, 2016 14:45:05 UTC Executing workflow item number 6
Aug 31, 2016 14:45:05 UTC Trigger context executeWorkFlowStep called
Aug 31, 2016 14:45:05 UTC Executing custom action Retrive_LOV_Values_v1 (End Loop)
Aug 31, 2016 14:45:05 UTC Executing custom action Retrive_LOV_Values_v1 (End Loop)
Aug 31, 2016 14:45:08 UTC End While task execution iteration no - 1
Aug 31, 2016 14:45:09 UTC Task #6 (Retrive_LOV_Values_v1 (End Loop)) completed successfully in 3 seconds
Aug 31, 2016 14:45:09 UTC Input/Output values for Task #6 (Retrive_LOV_Values_v1 (End Loop)):
Aug 31, 2016 14:45:09 UTC Completed workflow item number 6, with status Completed
Aug 31, 2016 14:45:09 UTC Executing workflow item number 3
Aug 31, 2016 14:45:09 UTC Trigger context executeWorkFlowStep called
Aug 31, 2016 14:45:09 UTC Executing custom action Retrive_LOV_Values_v1 (Start Loop)
Aug 31, 2016 14:45:09 UTC Executing custom action Retrive_LOV_Values_v1 (Start Loop)
Aug 31, 2016 14:45:12 UTC Start While task execution iteration no - 2
Aug 31, 2016 14:45:15 UTC Task #3 (Retrive_LOV_Values_v1 (Start Loop)) completed successfully in 6 seconds
Aug 31, 2016 14:45:15 UTC Input/Output values for Task #3 (Retrive_LOV_Values_v1 (Start Loop)):
Aug 31, 2016 14:45:15 UTC [Local Input: List based iteration = true]
Aug 31, 2016 14:45:15 UTC [Mapped Input: Input for list based iteration = left,right,center]
Aug 31, 2016 14:45:15 UTC [Local Input: User Input to assign iterated values = input_1_LOOPvar780]
Aug 31, 2016 14:45:15 UTC [Local Input: Count based iteration = false]
Aug 31, 2016 14:45:15 UTC [Local Input: Number of times to loop = ]
Aug 31, 2016 14:45:15 UTC [Output: START_LOOP_OUTPUT = right]
Aug 31, 2016 14:45:15 UTC Completed workflow item number 3, with status Completed
Aug 31, 2016 14:45:19 UTC Executing workflow item number 4
Aug 31, 2016 14:45:19 UTC Trigger context executeWorkFlowStep called
Aug 31, 2016 14:45:19 UTC Executing custom action Retrive_LOV_Values_v1 (If Else)
Aug 31, 2016 14:45:19 UTC Executing custom action Retrive_LOV_Values_v1 (If Else)
Aug 31, 2016 14:45:22 UTC Condition evaluated to False; subsequent Task is If Else
Aug 31, 2016 14:45:22 UTC Re-evaluting the flow to execute next task based on the condition providedIfElse_12043
Aug 31, 2016 14:45:22 UTC Completed workflow item number 4, with status Completed
Aug 31, 2016 14:45:26 UTC Executing workflow item number 5
Aug 31, 2016 14:45:26 UTC Trigger context executeWorkFlowStep called
Aug 31, 2016 14:45:26 UTC Executing custom action Retrive_LOV_Values_v1 (If Else)
Aug 31, 2016 14:45:26 UTC Executing custom action Retrive_LOV_Values_v1 (If Else)
Aug 31, 2016 14:45:29 UTC Condition evaluated to True; subsequent Task is Wait for Duration
Aug 31, 2016 14:45:29 UTC Re-evaluting the flow to execute next task based on the condition providedIfElse_12045
Aug 31, 2016 14:45:29 UTC Completed workflow item number 5, with status Completed
Aug 31, 2016 14:45:33 UTC Executing workflow item number 6
Aug 31, 2016 14:45:33 UTC Trigger context executeWorkFlowStep called
Aug 31, 2016 14:45:33 UTC Executing custom action Retrive_LOV_Values_v1 (Wait for Duration)
Aug 31, 2016 14:45:33 UTC Executing custom action Retrive_LOV_Values_v1 (Wait for Duration)
Aug 31, 2016 14:45:36 UTC Waiting 10 seconds
Aug 31, 2016 14:45:46 UTC Completed waiting 10 seconds
Aug 31, 2016 14:45:46 UTC Task #6 (Retrive_LOV_Values_v1 (Wait for Duration)) completed successfully in 13 seconds
Aug 31, 2016 14:45:46 UTC Input/Output values for Task #6 (Retrive_LOV_Values_v1 (Wait for Duration)):
Aug 31, 2016 14:45:46 UTC [Local Input: Duration = 10]
Aug 31, 2016 14:45:46 UTC Completed workflow item number 6, with status Completed
Aug 31, 2016 14:45:50 UTC Executing workflow item number 7
Aug 31, 2016 14:45:50 UTC Trigger context executeWorkFlowStep called
Aug 31, 2016 14:45:50 UTC Executing custom action Retrive_LOV_Values_v1 (End Loop)
Aug 31, 2016 14:45:50 UTC Executing custom action Retrive_LOV_Values_v1 (End Loop)
Aug 31, 2016 14:45:53 UTC End While task execution iteration no - 2
Aug 31, 2016 14:45:54 UTC Task #7 (Retrive_LOV_Values_v1 (End Loop)) completed successfully in 3 seconds
Aug 31, 2016 14:45:54 UTC Input/Output values for Task #7 (Retrive_LOV_Values_v1 (End Loop)):
Aug 31, 2016 14:45:54 UTC Completed workflow item number 7, with status Completed
Aug 31, 2016 14:46:00 UTC Executing workflow item number 3
Aug 31, 2016 14:46:00 UTC Trigger context executeWorkFlowStep called
Aug 31, 2016 14:46:00 UTC Executing custom action Retrive_LOV_Values_v1 (Start Loop)
Aug 31, 2016 14:46:00 UTC Executing custom action Retrive_LOV_Values_v1 (Start Loop)
Aug 31, 2016 14:46:03 UTC Start While task execution iteration no - 3
Aug 31, 2016 14:46:06 UTC Task #3 (Retrive_LOV_Values_v1 (Start Loop)) completed successfully in 6 seconds
Aug 31, 2016 14:46:06 UTC Input/Output values for Task #3 (Retrive_LOV_Values_v1 (Start Loop)):
Aug 31, 2016 14:46:06 UTC [Local Input: List based iteration = true]
Aug 31, 2016 14:46:06 UTC [Mapped Input: Input for list based iteration = left,right,center]
Aug 31, 2016 14:46:06 UTC [Local Input: User Input to assign iterated values = input_1_LOOPvar780]
Aug 31, 2016 14:46:06 UTC [Local Input: Count based iteration = false]
Aug 31, 2016 14:46:06 UTC [Local Input: Number of times to loop = ]
Aug 31, 2016 14:46:06 UTC [Output: START_LOOP_OUTPUT = center]
Aug 31, 2016 14:46:06 UTC Completed workflow item number 3, with status Completed
Aug 31, 2016 14:46:07 UTC Executing workflow item number 4
Aug 31, 2016 14:46:07 UTC Trigger context executeWorkFlowStep called
Aug 31, 2016 14:46:07 UTC Executing custom action Retrive_LOV_Values_v1 (If Else)
Aug 31, 2016 14:46:07 UTC Executing custom action Retrive_LOV_Values_v1 (If Else)
Aug 31, 2016 14:46:11 UTC Condition evaluated to False; subsequent Task is If Else
Aug 31, 2016 14:46:11 UTC Re-evaluting the flow to execute next task based on the condition providedIfElse_12043
Aug 31, 2016 14:46:11 UTC Completed workflow item number 4, with status Completed
Aug 31, 2016 14:46:14 UTC Executing workflow item number 5
Aug 31, 2016 14:46:14 UTC Trigger context executeWorkFlowStep called
Aug 31, 2016 14:46:14 UTC Executing custom action Retrive_LOV_Values_v1 (If Else)
Aug 31, 2016 14:46:14 UTC Executing custom action Retrive_LOV_Values_v1 (If Else)
Aug 31, 2016 14:46:17 UTC Condition evaluated to False; subsequent Task is If Else
Aug 31, 2016 14:46:17 UTC Re-evaluting the flow to execute next task based on the condition providedIfElse_12045
Aug 31, 2016 14:46:17 UTC Completed workflow item number 5, with status Completed
Aug 31, 2016 14:46:21 UTC Executing workflow item number 6
Aug 31, 2016 14:46:21 UTC Trigger context executeWorkFlowStep called
Aug 31, 2016 14:46:21 UTC Executing custom action Retrive_LOV_Values_v1 (If Else)
Aug 31, 2016 14:46:21 UTC Executing custom action Retrive_LOV_Values_v1 (If Else)
Aug 31, 2016 14:46:24 UTC Condition evaluated to True; subsequent Task is Wait for Duration
Aug 31, 2016 14:46:24 UTC Re-evaluting the flow to execute next task based on the condition providedIfElse_12047
Aug 31, 2016 14:46:24 UTC Completed workflow item number 6, with status Completed
Aug 31, 2016 14:46:27 UTC Executing workflow item number 7
Aug 31, 2016 14:46:28 UTC Trigger context executeWorkFlowStep called
Aug 31, 2016 14:46:28 UTC Executing custom action Retrive_LOV_Values_v1 (Wait for Duration)
Aug 31, 2016 14:46:28 UTC Executing custom action Retrive_LOV_Values_v1 (Wait for Duration)
Aug 31, 2016 14:46:31 UTC Waiting 10 seconds
Aug 31, 2016 14:46:41 UTC Completed waiting 10 seconds
Aug 31, 2016 14:46:41 UTC Task #7 (Retrive_LOV_Values_v1 (Wait for Duration)) completed successfully in 13 seconds
Aug 31, 2016 14:46:41 UTC Input/Output values for Task #7 (Retrive_LOV_Values_v1 (Wait for Duration)):
Aug 31, 2016 14:46:41 UTC [Local Input: Duration = 10]
Aug 31, 2016 14:46:41 UTC Completed workflow item number 7, with status Completed
Aug 31, 2016 14:46:41 UTC Executing workflow item number 8
Aug 31, 2016 14:46:41 UTC Trigger context executeWorkFlowStep called
Aug 31, 2016 14:46:41 UTC Executing custom action Retrive_LOV_Values_v1 (End Loop)
Aug 31, 2016 14:46:41 UTC Executing custom action Retrive_LOV_Values_v1 (End Loop)
Aug 31, 2016 14:46:44 UTC End While task execution iteration no - 3
Aug 31, 2016 14:46:45 UTC Task #8 (Retrive_LOV_Values_v1 (End Loop)) completed successfully in 3 seconds
Aug 31, 2016 14:46:45 UTC Input/Output values for Task #8 (Retrive_LOV_Values_v1 (End Loop)):
Aug 31, 2016 14:46:45 UTC Completed workflow item number 8, with status Completed
Aug 31, 2016 14:46:48 UTC Executing workflow item number 9
Aug 31, 2016 14:46:48 UTC Completed workflow item number 9, with status Completed
// handle the last item and the seperator
a=a+listOfCustomLOV.get(count++).getLovValue();
logger.addInfo("LOV output list: "+a);
logger.addInfo("Count: "+count);
// Count needs to be reduced by one
count--;
if (listOfCustomLOV.get(count).getLovLabel() == lovEntryFind) {
logger.addInfo("Found the entry returning this: "+listOfCustomLOV.get(count).getLovValue());
b=listOfCustomLOV.get(count).getLovValue();
}
output.LOV_Value = a;
output.LOV_Found_Entry_Value = b;
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: