Expressions in component parameters
When used for a component parameter, the following objects are of special interest:As an example, take a JDBC Connector with the Table Name parameter set to "Accounts". You could then click on the SQL Select parameter label or the Open parameter value dialog button adjacent to the field, choose Text w/substitution, and then enter this into the large text field at the bottom of the dialog:
Table 1. Special objects usable in Expressions Object Value config The Interface configuration object of the component. mc The MetamergeConfig object of the Config instance (config.getMetamergeConfig()). work The Work entry of the AssemblyLine. task The AssemblyLine object. select * from {config.jdbcTable}This will take the Table Name parameter and create the following SQL Select statement:select * from AccountsOr you could get more advanced, and try something like this for the SQL Select parameter:SELECT {JavaScript<<EOF var str = new Array(); str[0] = "A"; str[1] = "B"; return str.join(","); EOF } FROM {property:mystore.tablename} WHERE A = '{work.uniqueID}'The embedded JavaScript will return the value “A,B” which is then used to complete the rest of the Expression. If you have a Property Store called mystore with a tablename property set to “Accounts”, and a uniqueID Attribute in the Work entry with the value “42”, the final result will be:SELECT A,B FROM Accounts WHERE A = '42'This evaluated result is not displayed in the CE. Simply entering curly braces will not cause Expression evaluation to be done for the parameter value. Instead, you have two choices when tying Expressions to parameters:
- Press the Open parameter value dialog button adjacent to the field (or click on the Parameter label) and select Text w/substitution to open the Expressions dialog while in the parameter input field. You may enter your Expression in the large text field in this dialog. Click OK to enter your Expression.
- Type the special preamble, @SUBSTITUTE, manually into the parameter input field, followed by the Expression. For example:
@SUBSTITUTEhttp://{property.myProperties:HTTP.Host}/Note: This last method of entering expressions directly is not recommended; use the Expression Editor instead.
Parent topic:
Expressions