Tuesday
Hello!
In a Blue Prism object, I have the name of a Data Item stored as text in a collection. How can I retrieve the value of this Data Item dynamically based on the text (the name) stored in the collection?
Thanks for answer!
Tuesday
Can you tell me why you get this approach ?
Maybe we can do it differently
Show us your Business Object and then we can help you
Wednesday
Hello @Mohamad_747 !
I need to gather information about the inputs and outputs of actions within a Business Object. I already have code in place to retrieve the parameters (inputs and outputs) of a given method, but I’m unable to acquire their values.
For example: I have an action that only has one output (of type flag). Here is a screenshot of the action’s inputs/outputs:
What I need is to retrieve the value, which is stored in a data item:
If I have the name of the output data item, how can I get its value?
Thank you so much for any advice!
Wednesday
@EwelinaFHlag hi,
Just to understand, suppose for example in your collection "data table" column "parameter name" you have instead of 'valid' the value 'result' so you will have an output with the same name 'result' ?
Wednesday
Exactly, there would be a data item called 'result'
Wednesday
This data item wil be generated automatically?
Wednesday
No no, the data item already exists. I just wonder - how to obtain its value once we have the name of data item.
Wednesday - last edited Wednesday
I think we should do it differently, especially if the outputs are flags. If they were texts, we could have put decisions and checked if the text is empty or not. What I propose is to add a column to the "data table" collection called value and which puts the value of the parameter name column. To do this, we will have to code something to add this function. If you are ok with that i need to understand what your code stage do and i could perhaps help you.
Thursday
I have following code:
string variableName = inputVariableName; // Example of a variable from the Data Table that stores the variable name, e.g. 'valid'
// Attempting to get a field (variable) named e.g. 'valid' in the object of this class
var field = this.GetType().GetField(variableName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
if (field != null)
{
// The variable was found, retrieving its value
object value = field.GetValue(this); // Reading the value of the variable
outputValue = value.ToString(); // Assigning to the output variable
}
else
{
// Attempting to read the property if the variable is a property (not a field)
var property = this.GetType().GetProperty(variableName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
if (property != null)
{
// The property was found, retrieving its value
object value = property.GetValue(this);
outputValue = value.ToString(); // Assigning to the output variable
}
else
{
// The variable or property was not found
throw new Exception("The variable named '" + variableName + "' was not found.");
}
}
following input is provided to the code stage:
where [data table.Parameter Name] is 'valid'.
However, when I run this code following error is found:
ERROR: Internal : Could not execute code stage because exception thrown by code stage: The variable named 'valid' was not found.
Data item 'valid' is located on the same page as the code stage. I tried to change it's visibility to public, but it didn't work.
I'm not sure why this data item cannot be found.
Thursday - last edited Thursday
Hi @EwelinaFHlag ,
Correct me if i'm wrong.
You have some logic which decides the name of the data item from which the value to be taken for processing.
so now we need to have the logic to verify that the data item has the value, if it has then you need that value as output?
Thanks,
Nandha