I am wondering if there is a way to automatically map data fields to a pre saved datamapper.
We have a Datamapper we use for most jobs which incorporated the Quad One barcode for reporting purposes.
We open this datamapper and drop our new data in, we have fields in our data that match the fields in the datamappers data model. But it doesn’t seem to realise that the field name are the same, and we have to manually drag each field from the data panel to the data model panel as to map them.
My thoughts… or should I say guess work. (The fields in the data model are all set Javascript for a specific reason which is presumably why they are not mapping as it they would need to be set to location to map.)
Does anyone have a workaround, solution, or possible answer to this datamapping conundrum?
Appreciate the big brains helping out on this one!
This should work for Excel files and databases (if the column names are the same in all data files) and for XML (if the elements’ XPATHs are the same in all data files).
If you can anonymize your data, it would be helpful if you could provide a sample DataMapper configuration along with an additional data file that replicates the issue.
Your data model contains a series of fields (A1 to A9) that are set to extract, through JavaScript, "". And you were expecting that the DataMapper would automatically associate any field name A1 … A9 in the data file to the corresponding field in the data model.
But that’s not how the DataMapper works: even if it were able to automatically match the data model field with the corresponding CSV column, it would still extract an empty value since your JavaScript code is hardcoded to the "" value.
Here’s what you could do instead: for each field you actually want to extract from the CSV data, use JavaScript code like this:
try{
data.extract('A1',0);
} catch (e){
"ERROR: field not found"
}
That way, if A1 is present in your data file, it gets extracted, otherwise, instead of erroring out, it simply extracts an error message (or you could replace that with an empty string if you want).
So with the sample data file you provided (which does not include fields A7, A8 and A9), the extracted results looks like this:
Sorry, I should have mentioned we are using the Swiftsort plugin in our workflows which then pre-populates the fields when a workflow is running.
So if we use the javascript code to extract the data when building a stand-alone job, then it fills the fields in, which is great.
But my previous question was to establish if we send this datamapper to the workflow then try to use it in a workflow which uses the Swiftsort plugin would it work basically.
I hope that makes more sense… Apologies for the confusion!
I am not familiar with the Swiftsort plugin, it isn’t part of the standard set of tools for Workflow.
Many of our partners develop their own plugins (and so do some of our own Professional Services people!) but since those modules are not part of the standard distribution, I can’t comment on how they work.
Perhaps you could ask the person who installed and/or developed that plugin?
We currently use the Swiftsort plugin for many of our workflow jobs, which is fine.
Let me briefly explain,
When we build a one-off job, the customer then wants to make this a repeat job, and this is the point where we need to set up a workflow.
What I am trying to establish is if we can use the same template and datamapper used for a one-off job can also be used for the workflow or is this not possible and a rebuild of these is required for the workflow separately.?
I understand these work differently, with one using metadata and the other does not.
There is only one type of datamapper and template so you should be able to use the one-offs in the workflow as well. Just make sure that the field names in the datamapper use just aphanumeric characters (avoid anything fancy or spaces).