Links

Passing Parameterized Fields

In this section you will learn how to pass parameterized fields (user ID, file IS, uploader ID, company ID etc.) that will be invisible to the user.
Parameterized fields in Osmos allow you to programmatically pass variable values that provide additional information related to the specific uploader, without requiring the user to manipulate the data themselves. Parameterized fields can be defined by setting `fieldType` in the schema supplied in the Osmos Uploader embed snippet. There are several available options to choose from:
  • "fileName" will be populated with the name of the file uploaded by the user
  • "constantValue" will be populated with whatever value is provided in an attribute named constantValue for that same field
  • "userID" and "userGroup" are a special parameterized field tied directly to Uploader Recall
To learn more about how userID and userGroup can be used to tailor Uploader Recall, visit Customize Osmos Recall
These fields will not be visible to the user or accessible by them in any way. If a user ID or user group field is used but no user id or group is set, the fields will default to empty string.
Note:
  • userID and userGroup param are defined outside the schema
  • fileName param does not need to be defined. It gets populated automatically for any schema field with a fieldType of fileName.
  • constantValue param should be defined inside the schema
Here's an example of using a userID parameterized field which populates a field called user_id for every row by pulling the the property curUserID from the browser.
<script>
Osmos.configure({
userID: window.curUserID,
schema: {
fields: [
{
name: "user_id",
fieldType: 'userID'
},
...
]
},
...
});
</script>
In this example, we add a return a parameterized named upload_name which is set to the name of the uploaded file.
<script>
Osmos.configure({
schema: {
fields: [
{
name: "upload_name",
fieldType: 'fileName'
},
...
]
},
...
});
</script>
Here's an example of using a parameterized field that fills in the provided constantValue for that field in all rows:
<script>
Osmos.configure({
schema: {
fields: [
{
constantValue: '02042022',
name: "const_field",
fieldType: 'constantValue'
},
...
]
},
...
});
</script>
An uploader that includes all types of parameterized fields along with four other standard mapped fields, might look like the javascript below. A user of this uploader will be able to map and transform the first four fields listed, and the resulting document written to the destination will contain seven fields total.
<!-- Osmos File Upload Button -->
<!-- See this link for more docs. https://docs.osmos.io/osmos-uploader/webpage-integration -->
<script src="https://cdn.osmos.io/button/embed/v1/OsmosButton.js"></script>
<script>
Osmos.configure({
userID: window.curUserID,
schema: {
fields: [
{
name: "ProductID",
displayName: "ProductID",
description: "<Your field description here>"
},
{
name: "FirstName",
displayName: "FirstName",
description: "<Your field description here>"
},
{
name: "LastName",
displayName: "LastName",
description: "<Your field description here>"
},
{
name: 'paymentType',
displayName: 'Payment Type',
description:'The medium of payment which was used to complete the transaction'
},
{
name: "user_id",
fieldType: 'userID'
},
{
name: "upload_name",
fieldType: 'fileName'
},
{
constantValue: '02042022',
name: "const_field",
fieldType: 'constantValue'
}
]
},
token: "example_some_uploader_token_uuid_example",
uploadDescription: "<Include a description of your uploader upload here which will be shown to users that click the uploader>",
// Set to false to show the schema for the destination connector in the uploader on the file upload screen.
hideUploadSchema: true,
// Set to false to show the uploader description on the file upload screen.
hideUploadDescription: true,
// Set to false to show the advanced version of the uploader, with formulas, SmartFill, and QuickFixes.
disableAdvancedMode: true,
// Maximum number of records displayed in the Uploader UI (User Interface).
// This value is capped at 100,000 and higher values will default back to 100,000.
// Can be lowered to increase UI performance when using expensive validators.
// NOTE: Your file can have >100,000 rows and will be processed fully. There are no limits to how many records can be uploaded.
// This setting only limits the number of rows displayed in the UI.
maxRecords: 100000,
// Set to true to hide the preview pane screen for CSV files in the uploader.
hideCSVPreviewPane: false,
});
</script>
<button class="ftl-button" onclick="Osmos.handleClick('w9ziodyyfx4mq6wl2tw1y6dpp6tctfardjeuqsl_n0i-gtsbb')">
Upload Your Data
</button>
<!-- End Osmos File Upload Button -->