Write a component with a setting
Create a component that changes one field of a message, with a setting to choose the field.
Táto stránka ešte nie je preložená. Čítaš originál.
Na tejto stránke
This recipe builds Uppercase, a component that turns one text field of the incoming object into capital letters. A setting lets you choose the field.
Create the component
1. Select Add (plus), then Create new component.
2. Replace the whole template with this code:
<script total>
exports.id = 'uppercase';
exports.name = 'Uppercase';
exports.icon = 'ti ti-font';
exports.author = 'Demo project';
exports.version = '1';
exports.group = 'Demo';
exports.config = { field: 'name' };
exports.inputs = [{ id: 'input', name: 'Input' }];
exports.outputs = [{ id: 'output', name: 'Output' }];
exports.make = function(instance, config) {
instance.message = function($) {
var data = $.data;
if (data && typeof(data[config.field]) === 'string')
data[config.field] = data[config.field].toUpperCase();
$.send('output', data);
};
};
</script>
<readme>
Changes one text field of the incoming object to capital letters.
</readme>
<settings>
<div class="padding">
<ui-component name="input" path="?.field" config="required:1">Field name</ui-component>
</div>
</settings>
<body>
<header>
<i class="ICON"></i>NAME
</header>
</body>3. Select APPLY. Uppercase appears in the Demo group on the left.
Use it
- Set the Trigger to send an object, as in Your first flow.
- Drag Uppercase onto the canvas.
- Connect Trigger to Uppercase, and Uppercase to Print.
- Select APPLY and confirm.
- Select Run on the Trigger.
Print shows the object with the name in capital letters. Double-click the Uppercase node to choose another field.

Share it
Save the code as uppercase.html. You can drop the file on another FlowOS, or put it on a web server and install it with Link component. See Add components.
To learn more about the component format, see the Flow development guide.