$(document.sequence.job) in vbscript

Would anyone be able to help me with what looks like a simple problem that I cannot find an answer for?

I have a mailing process that needs to send a fixed width text file to a mailer inserter as a control file for the inserter. I am trying to use a vbscript that does this but I would like to use the $(document.sequence.job) variable that gets used in the barcode on the printed piece but I do not know how to call it in vbscript. the script I am using is below which is failing on the jobSequence variable.

All variables using the metadata work fine its just the document sequence I need.

I would appreciate any help on this. Thanks

Option Explicit
Dim MyMeta, x, MyCSVLine, FSO, ft, Filename, jobSequence

Set MyMeta = CreateObject("MetaDataLib.MetaFile")
MyMeta.LoadFromFile(Watch.GetMetadataFileName())

Filename = MyMeta.Job.Group(0).Document(0).FieldByName("_vger_fld_JobID")
jobSequence = ${document.sequence.job}

'create CSV
Set FSO = CreateObject("Scripting.FileSystemObject")

Set ft = FSO.OpenTextFile("\\filepath\output\0000"+Filename+".jaf",2,True)

ft.WriteLine("H0000"+Filename)

'for all documents in group 0
For x = 1 to MyMeta.Job.Group(0).Count
        'add new CSV line
        MyCSVLine = "B" + Right(String(10,"0")& MyMeta.Job.Group(0).Document(x-1).FieldByName("_vger_fld_JobID"),10) +_
                    Right(String(10,"0")& jobSequence,10) +_
                    Left(MyMeta.Job.Group(0).Document(x-1).FieldByName("_vger_fld_sft_MailmarkSeq")& Space(8),8) +_
                    Left(MyMeta.Job.Group(0).Document(x-1).FieldByName("_vger_fld_LetterType")& Space(30),30) +_
                    Left(MyMeta.Job.Group(0).Document(x-1).FieldByName("_vger_fld_OrigName") & Space(112),112)
        ft.WriteLine(MyCSVLine)


Next
ft.Close
Set FSO = Nothing
Set MyMeta = Nothing

You can’t access that value directly from a Workflow script.

To achieve this, I think you would have to use the Connect REST API to obtain the various values for each document.

I will leave it to someone with more experience on that topic to explain how to go about it.

OK, thanks Phil, That sounds like it is beyond my current abilities at the moment.

As far as I know ${document.sequence.job} means document count within the job (= record nr).
So why don`t you count the documents in metadata? I am not that deep in metadata scripting, so it is only an idea…

If it is true that, when using grouping and sorting in a Job creation process, the metadata after that process in the workflow is sorted according to the settings in the job creation process that it should be feasible to use the document number in the metadata. Would someone be able to confirm this? I will try in the coming days to set up a test workflow to check this.

Sorry, my fault. Of course your Connect metadata in Workflow will be created in the Datamapper step, so no output grouping etc will be considered.