How to accomplish drop-down lists in KIE workbench? - workflow

I'm new to JBPM and am trying to wrap my head around a new project, and recently noticed that while trying to define some user task forms I couldn't find a form option for a drop-down list
At this point my knowledge of the technology is pretty small, and this seems like a strange limitation at first glance, which should have an easy work-around, but I'm having difficulty finding a quick and dirty solution.
Is this something I'd have to code in Eclipse, or something else?

The answer that #cego provides is correct for "hard-coded" values, if you want to load dynamic values (from a database for example) you can use the Select Box field type and configure it to use a SelectValuesProvider that calculates the combo values.
To create a SelectValuesProvider you should create a java project with a mvn dependency to:
<dependency>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-form-modeler-api</artifactId>
</dependency>
Once you did that you can create your class that implements org.jbpm.formModeler.core.config.SelectValuesProvider. This interface provides two methods:
String getIdentifier(): should return a unique String that identifies this provider. This String will be shown on the Select Box configuration popup.
Map getSelectOptions(Field field, String value, FormRenderContext renderContext, Locale locale): This method have to return a Map containting the key, text that are going to be load on the Select box. The received parameters are:
Field field: the configuration of the field that is going to be evaluated.
String Value: the current value of the field
FormRenderContext renderContext: a class that contains all the information about the form that is rendered at that moment.
Locale locale: the locale in which is being rendered the form.
Once you've created this provider, you must compile your project and put the jar on the server classpath and restart it. After doing that you'll be able to create a form (or edit an existing one), add a Select Box field and choose your provider on the "Data provider" combo box.
Hope it helps, if you have any doubt please ask and I'll try to create an example.
Regards,
Pere

Ok, for old versions you can do it turning a textbox to a combobox using a RangeProvider. This is a very similar solution to the previous one.
First you should create java project with a mvn dependency to:
<dependency>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-form-modeler-api</artifactId>
</dependency>
After that you have to create your RangeProvider class that implements org.jbpm.formModeler.api.model.RangeProvider and implement it's methods. As the SelectValuesProvider on the previous example this interface provides two methods:
- String getType(): A unique String to identify the provider
- Map getRangesMap(String namespace): This method have to return a Map containting the key, text that are going to be load on the combo box. It only receives a String parameter, it is an identifier that allows you to get all the information about the form that is being rendered.
Also you have to create a META-INF/beans.xml file to allow to lookup your provider via CDI (I missed this step on the previous example, sorry).
As the previous example, once you've created the provider you must compile your project and put the jar on the server classpath and restart it.
When the server is started you have to create a new form (or open an existing one), add a TextBox field, edit it's properties and write the string returned by your RangeProvider's getType method on the "Range value" property.
Save the field properties and if everything is fine the field would be rendered as a combobox showing the values returned by your provider.

To create a select element(drop-down list) look for "Setting a Range Formula" in this part of the documentation: http://docs.jboss.org/jbpm/v6.1/userguide/chap-formmodeler.html#sect-formmodeler-FormulasExpression

Related

How to customize email template in crm 2016 by code

I am using CRM 2016, and trying to customize email template by adding a dynamic data. I know that CRM allows to use only specific vanilla entities, but when I explorer an old code I found an option to use {0}, {1} etc' for injecting data from non vanilla entities (by code) - unfortunately that code cannot be tested...
Have someone heard or know about that way? is it possible? what to google for?
You can do this by manually typing similar marker what CRM is using. Note that this is not documented in SDK.
Dynamic Values For Custom Entities In Email Templates
In the template, where you want the value to appear, type within 2 brackets an exclamation point followed by the entity logical name. After the entity name, add a colon, and then the field logical name, ending it with a semi colon. If you’d like a default value if nothing was found, after the semi colon add the default value.
{!<entitylogicalname>: <fieldlogicalname>; <Default Text>}
More in part 2:
The Global Template Type is what you’d want to use for custom
entities, or any other entity not listed in the template type drop
down menu. And just to reiterate, regardless of the way you insert
values, whether you use the out of the box insert method or you
manually type it in, you can only insert values from one record.
Dynamic Values For Email Templates - Part 2
Dynamics' email templates are flawed. You either can't use custom entities or you have no translation. I use this workflow instead. It can do everything : https://github.com/rtebar/dynamics-custom-emails

Seperate error messages for required TextFields and DropDownChoices

I'm currently working on a Wicket 6.20 project which already has dozens of pages with TextFields and DropDownChoices. Now the requirement came up to change the default '${label}' is required. message to something more specific, depending on whether a TextField or a DropDownChoice doesn't have a value.
I know I can put Required=My Text in a properties file of the application, but that changes the message for all FormComponents. And specifying the full component path to either the TextFields or the DropDownChoices in the form of myform.mycontainer.mydropdownchoice.Required=My Text isn't feasible, since of course the structure of the Forms can differ on each page.
Ideally I'd like to put something like
org.apache.wicket.markup.html.form.DropDownChoice.Required=Please select a value for '${label}'
org.apache.wicket.markup.html.form.TextField.Required=Please enter a value in '${label}'
in my application's property file, either with or without FQCN.
Is there a way to achieve this with any of the default IStringResourceLoader that come with Wicket?
It is not necessary to provide the complete path to the components. It could be a path with just few parents:
mycontainer.mydropdownchoice.Required=My Text
mydropdownchoice.Required=My Text
If this still is not an option then you can override org.apache.wicket.markup.html.form.FormComponent#reportRequiredError() for any instance or type (e.g. MyDropDownChoice).

How to define a function for use in an ODM decision table w/o changing the XOM?

I'm using ODM 8.5 (the JRules successor). In my Java domain, I have a three-character String field that represents a number, "000" to "999". I'd like to have a decision table that represents logic like:
if field is between "000" and "012" then set the result to "tiny"
if field is between "013" and "060" then set the result to "less tiny"
...
IBM's documentation on defining columns states - "A condition statement is an incomplete BAL predicate expression...". Is there anything in the BAL that does the kind of String comparison I want to do? If not, is it possible to call a function defined in the IRL from the BAL? If so, how? I'm also open to other suggestions on how to handle this simple problem in ODM (without changing the existing Java XOM). Right now, it looks to me that I can't use an ODM decision table, although the underlying logic seems well-suited to a decision table.
This answer is heavily based on Justin Phillips's nice answer to this question, updated for ODM 8.5. Please plus up his answer.
The main idea is to create a function in the Business Object Model (BOM) that can be called from your rules. To add a BOM function:
Right click the bom folder in the Eclipse rules project.
Select New -> BOM Entry from the menu.
Select the Create an empty BOM entry option and then click Finish.
Double click the new BOM entry to bring up the BOM editor view, and
then click New Class.
Enter the class name and then click Finish.
Double click the new BOM class from the list, then under
the Members section, click the New button.
In the New Member
dialog, select the Method option, enter a Name (isBetween),
return Type for the method (boolean), and add three String parameters (testee - the value being tested, min and max). Click the Finish button.
Double click the new method under the Members section, and select the Static and Final options.
Click the Create link under the "Member Verbalization" section and fill in the Template text box with {0} is between {1,min} to {2,max}
Under the BOM to XOM Mapping section, enter your Java code.
11. Go back to the class level BOM editor and set the Execution name to the value void in the "BOM to XOM Mapping" section. This indicates that the BOM class is not linked to a Java class (XOM).
The verbalization for the newly created member should now be accessible when filling out the Test in the Condition Column for the decision table.

Symfony2: Entity instantiation upon Form-Submit depending on user selection

I'm working with Symfony2 to set up a form, where a Shelf-Entity can be edited.
A shelf contains a collection of Readable-Entities (e.g. Book, Magazine, etc. - all inherit from Readable).
The user has the possibility to add more Readable-Entities (the form is extended via JavaScript) and from a dropdown he can select the type of Readable he wants to add. Depending on the selected dropdown-value, different form fields are rendered. So far so good.
Now, when the form is submitted to the server, depending on the Readable-Type the user selected in the form, a different entity-type should be instantiated.
If I don't do anything, Symfony just instantiates the base class Readable (and not Book, Magazine, etc.).
How can I tell Symfony to instantiate the correct type of Readable depending on the selected value from the dropdown?
I tried with FormEvent-Listeners, but:
in PRE_SUBMIT I only get an array containing the "raw" form data with $event->getData(), i.e. no entities have been instatiated so far. However, at this stage, I still have access to value of the dropdown.
in SUBMIT the form data was already assigned to the appropriate entities. Also the new Readable was already instatiated with the base Readable-Class. But now, I cannot access anymore the value from the dropdown.
What is the correct way to do this?
EDIT
Added a minimal Code-Example for the Shelf FormType:
https://gist.github.com/anonymous/401495b701982adafb96
Code for infinite_form_polycollection:
https://gist.github.com/anonymous/b5f0ed10ca9c52177f01
Have you tried looking at this part of the doc? As "embedding a form" seems to fit your needs.
It seems that there was something wrong with the PHP-Files of the PolyCollection in the vendor-directory, because after removing everything related to the Infinite Form Bundle from the vendor-dir and reinstalling it with composer, everything is working now. But thanks for your efforts YoannCh

How to make dynamic drop down lists on parameterized build page in a custom Hudson plugin?

I am trying to achieve the following for a parameterized hudson job: when a user clicks on 'build now' he should be presented with three drop down list parameters viz., Environment, Server, Port. I want the drop down to be dynamic i.e on changing the value of environment the list of servers should change accordingly and similarly the values of port should change on the basis of selected server.
Once a user makes the final selection, all three values from the dropdowns are to be used to make a single value to be passed to the build job as a parameter. I am stuck at how to achieve this in a single parameter and make it dynamic. In my custom plugin i have extended the ParameterDefinition class and within it i have a static nested class extending the ParameterDescriptor class with doFillXXXItems() for these three fields. The values in environment dropdown are populated on the basis of logged in username. I would really appreciate it if somebody could help me figure out how to make the drop downs dynamic. I have already tried the dynamic drop down listbox in ui-samples plugin but its not working in my case :(
You could inherit hudson.model.ChoiceParameterDefinition, and override its method of getChoicesText. return the options based on whatever you want, in your situation, you could get environments from Hudson.getInstance().
Below snippets is shown how get environment variable.
Hudson.getInstance().getGlobalNodeProperties()
.get(EnvironmentVariablesNodeProperty.class).getEnvVars().get(name);