Populating a drop down
Summary: scottbenson started a discussion seeking advice on automating the population of a dropdown field in a workflow form by pulling in values from an existing attribute, rather than hardcoding them. Stefan Busch (Stefan Busch) responded with two options: one for using existing attribute values and another for all possible values of an attribute type. scottbenson appreciated the guidance and attempted to implement the suggestions. However, when facing issues with the implementation of the second option, Stefan Busch provided a refined script adaptation to address potential issues, specifically focusing on attribute type compatibility.
Has anyone written code they would be willing to share to populate a field in the workflow designer based on the values stored in the attribute? In other words:
I have an attribute with about 10 different values (doc, xls, pdf, etc).
I have created a form that allows users to pick the value they want to use.
Rather than storing the values in collibra AND hard coding them into the form, I figure there has to be a way to read the values from the attribute and place them into the drop down on the form. RIght?
thanks
Stefan Busch
·10 months ago · EditedHi,
One question for clarification. Do you want the user to select the value from an existing attribute or from the possible values of an attribute type?
Cheers
S Benson
OP10 months ago · Edited@Stefan Busch I want to use attributes from an existing attribute with existing values. For instance, the attribute "Attachment type" could have values of "Doc, Txt, PDF, XML, etc". Upwards of 20 values that I dont want to hard code into the form.
Thanks again.
Stefan Busch
·9 months ago · EditedHi,
ok so here are two options:
Populating the drop-down with values from an existing attribute (so an attribute that is part of some asset and which somebody chose some values for). In this case I assume that the attribute is a multi-select attribute type (otherwise there could only be one value and the wouldn't need a drop-down).
The second option is for the case that you want to populate the drop-down with all possible values that an attribute type can have (and not only the ones that were selected by some user for a specific attribute)
The variable 'singleSelectDataSource' is then used as the input for the items of a 'Single Select' component in a Collibra form.
S Benson
OP9 months ago · EditedPERFECT!!! That was exactly the type of help I was looking for. I will try both versions (you were correct, i needed both) and let you know how things turned out!
Scott
S Benson
OP9 months ago · EditedStefan,
I tried to implement your second version and was unsuccessful.
I substituted the UUID of my attribute for attribute_id in row 2.
The form, which has many variables is associated with the Start event.
The workflow deploys correctly, but when I attempt to start the workflow from the dashboard I receive the dreaded "Workflow unable to start" error. I'm sure your code is correct, I figure I am doing something wrong - I know I'm close.
Thanks again,
Scott
Stefan Busch
·9 months ago · EditedHello Scott,
the only case where I could see it fail right now is, if the attribute type is not a (multi) selection attribute type (because in this case the 'getAllowedValues' method does not exist).
I did add an extension to the script to catch that case
The way my small test workflow works is:
User task where you can select an attribute type (I use the 'Attribute Type' component which is then stored in the variable with the name 'attributeTypeId')
Script task with the code above
User task with a 'Select (single)' component
I would upload it but I don't see an option to add a file here
S Benson
OP9 months ago · EditedStefan,
I got it to compile - i had to change attributeTypeApi.getAttributeType(string2Uuid(attribute_type_id)) to
AttributeType attributeType = attributeTypeApi.getAttributeTypeByName("Field Name")
Now I need to convince it to actually load the data into the form.
And then repeat the process for each attribute.
and figure out relationships.
But you got me going in the right direction - very much appreciated!
Scott