Output data model to a positional text file

Hi,

I have multiple input files that are being mapped to a standard data model. Then I need to output the model into a positional text file and I have a few questions:

  1. I’m wondering if I should be doing this in a designer template ou directly in the workflow?
  2. From what I am seeing (new to connect) I will need to use a script to output into a positional format, is this correct?

Thanks for the help.
Pascal

Please refer to this similar case.

Thanks,

I output the record in Metadata in the Excecute Data Mapping task.
Ran in debug mode to view Metadata image

Then in the Create File task I have the following
GetMeta(_vger_fld_Numero_de_paiement[0], 8, Job.Group[0].Document[0])
When the step execute I get the following

[0004] W3000: Error parsing: Error resolving data selection: Error loading metadata file: file not found.

Here is the workflow.

Thanks for your help.
Pascal

You can’t use a reference to a previous metadata file in the Create File task because it is an input task that discards the previous metadata.

What you have to to is add a Set Job Infos and Variables task between the Execute Data Mapping and the Create File tasks, store your metadata value in a variable or a JobInfo, and then use that variable or JobInfo in your Create File task.

That worked.
Now my data model is as follow
image

From what I am seeing, the export to metadata gives me access to the record level. Is there any way to get access to the other levels (detail, inv_detail) from workflow? Maybe with the Run Script task?

Thanks

If you want the detail tables, you’ll have to use a Retrieve Items task and select JSON as its output type. You can then process that JSON file using a JavaScript task.

So keep your Execute Data Mapping task, but set its output type to IDs in Metadata.

Then insert a Retrieve Items task and configure it as follows:

  • set the Entity to retrieve to Record Set
  • set the Retrieve by to Record Set ID
  • insert a metadata reference in the Record Set ID (usually GetMeta(_vger_recordset_id[0], 10, Job.Group[0]))
  • tick the Records in JSON option

After that task has run, the data file will be the JSON file, which you can process in a script.

Great,
Thanks, I will looking to this in the next few days.

Was able to get the json created and validated with View as Text during debugging.
Now I am having trooble assessing the json in the javascript. What is the method for doing this. Is it the loadjson, does not seem relevant seeing that it is not external but internal to the process.

or something like this (found it on another post)?

var xhttp = new ActiveXObject(“Microsoft.XMLHTTP”);
var contentsetid = Watch.ExpandString(“GetMeta(_vger_contentset_id[0], 10, Job.Group[0])”);

var url = “http://localhost:9340/rest/serverengine/entity/contentsets/” + contentsetid + “/pages?detail=true”;
xhttp.open(‘GET’,url,false);
xhttp.setRequestHeader(‘Content-Type’, ‘application/json’);
xhttp.onreadystatechange = handlerGetDataRecord;
xhttp.send();

Thanks

In a Workflow script, all you have to do is read the contents of the current Job file, which is accessed though the %c system variable.
So your JS code would look like:

var contents = Watch.ExpandString("%c");
var myObj = JSON.parse(contents);

Great,
That did it.
Thanks a lot.

The only problem I got left is the output to a local file.
Can it be done within javascript?
I am trying to use a local variable and then run a create file with a send to folder after, but the variable does not keep the new lines that I am using in the script.

Thanks

Thought of an option

  1. replace the new line by a semi-colon
  2. run a 2nd Run Script task in VBScript to do the output.

Is there another option?
Thanks

Not sure why this wouldn’t work for you. The steps are fairly straightforward:

  • In a script, you parse the contents of your JSON file and store that in a JS variable (as I showed in my last post)
  • In the same script, make changes to that variable by adding whatever needs to be added, including newline characters (\n)
  • Finally, still in that script, store the variable’s modified contents to a local process variable named myJSON:
    Watch.SetVariable("myJSON",JSON.stringify(myObj)); )
  • Then, add a Create File task immediately after the script, with the following content:
    %{myJSON}

Just tried it again and get the same result

Better open up a call with our Support team, I am not quite sure what kind of output you are trying to produce and what kind of script you wrote to get there. This will probably take only a few minutes to fix.

Got it to work.
Your exemples were stop on. Must have been something I was doing.

Thanks,
Pascal