Call local variable from script (JavaScript)

I need to call the local variable (% {Date_Install}) inserted in the process, get its value, put it inside a variable declared in JavaScript, change the obtained value to date format and put the modified value back into the local variable ( % {Date_Install}) for Workflow to place it in one of the fields the Output to SharePoint plugin

In a Workflow script you can call a local variable with Watch.GetVariable(“”).

JavaScript Example:

var DateInstall = Watch.GetVariable("Date_Install");
DateInstall = new Date(DateInstall);
Watch.SetVariable("Date_Install",DateInstall);

Hope that helps.

Note that using the alternative

var DateInstall = Watch.GetVariable("DateInstall");

would be slightly more optimized than using ExpandString().
As a rule of thumb, you use ExpandString() when you want to evaluate a combination of dynamic values.

Argh, you are so right. I would never use ExpandString in that case for myself. I do not know why I wrote that here. :see_no_evil:

Thanks for the reply

I have tried the example code but when I run the script it gives me the following error:

W3602 : Error 0 on line 5, column 1: Script.NamedItemWatch: Error getting variable “%{DateInstall}” value: Variable “%{DateInstall}” does not exist

Sorry, again my mistake. Your variable is named Date_Install and in my example the variable is named DateInstall.

I edited the example in my first answer now.

Thanks for your help

Please can someone tell me how to compose variable data with PRes Workflow. I can use PReS Designer very well but am having errors using workflow. like metadata not found the the output pdf comes in .dat and cant open it. Please help out if you know how. Thank you.

In Workflow, you will have steps that get the data from wherever it comes from and feed it to the Execute Datamapping plugin. This one will have been set to use the Datamapper you have sent to Workflow from the Designer (CTRL-F12 or File->Send to workflow…).
Next, you’ll add the Connect plugin which will create your output: Create Web Content, Create email Content or Create Print Content.
Next you’ll have, when the output desired is PDF or print, a Create Job and Create Output plugin.

If you see a .dat file as the result, it is because there was an error somewhere in previous steps.
You should read our documentation on this and watch our videos on the subject

Thank you very much for the prompt responds. I have tried directed and i read the documentation, it really helpful but am still have errors .Please below and direct further on what i have not done correctly when debugging:.

Start debugging.
Using schedule for EMS_JOB

WPROC: EMS_JOB (thread id: 4444) - 13:00:52

[0003] Starting plugin Create Print Content - 13:00:52
[0003] Default Server IP address: localhost
[0003] Parsed Default Server IP address: localhost
[0003] Default Server Port: 9340
[0003] Parsed Default Server Port: 9340
[0003] Source data is MetaData
[0003] W3001 : Error while executing plugin: W3886 : Metadata file to append: “C:\ProgramData\Objectif Lune\PlanetPress Workflow 8\PlanetPress Watch\Debug\debugACE0CA4.dat.meta”, was not found
[0003] Create Print Content: W1603 : Plugin failed - 13:00:52 (elapsed time: 00:00:00.002)

[0004] Starting plugin Create Job - 13:00:52
[0004] W3001 : Error while executing plugin: W3886 : Metadata file to append: “C:\ProgramData\Objectif Lune\PlanetPress Workflow 8\PlanetPress Watch\Debug\debugACE0CA4.dat.meta”, was not found
[0004] Create Job: W1603 : Plugin failed - 13:00:52 (elapsed time: 00:00:00.001)

[0005] Starting plugin Create Output - 13:00:53
[0005] Default Server IP address: localhost
[0005] Parsed Default Server IP address: localhost
[0005] Default Server Port: 9340
[0005] Parsed Default Server Port: 9340
[0005] W3001 : Error while executing plugin: W3886 : Metadata file to append: “%s”, was not found
[0005] Create Output: W1603 : Plugin failed - 13:00:53 (elapsed time: 00:00:00.001)

[0006] Starting plugin Send To Folder - 13:00:53
[0006] Path: c:\out
[0006] Parsed path: c:\out
[0006] Filename: %f
[0006] Parsed filename: debugACE0CA4.dat
[0006] File sent : c:\out\debugACE0CA4.dat, size: 6482 bytes
[0006] Plugin Send To Folder completed successfully - 13:00:53 (elapsed time: 00:00:00.001)

WPROC: EMS_JOB (thread id: 4444) complete - 13:00:53 (elapsed time: 00:00:00.918)

Start debugging.
Using schedule for EMS_JOB

WPROC: EMS_JOB (thread id: 7916) - 13:04:35

[0002] Starting plugin Execute Data Mapping - 13:04:35
[0002] Default Server IP address: localhost
[0002] Parsed Default Server IP address: localhost
[0002] Default Server Port: 9340
[0002] Parsed Default Server Port: 9340
[0002] Sending file data source…
[0002] File Data Source ID: 64747491
[0002] Sending data mapping command…
[0002] Cached version not available, attempting to upload file.
[0002] Using cached configuration file (id = 64747492).
[0002] Starting data mapping operation…
[0002] [2021-04-09 13:04:35.516] Record creation> Retrieving results
[0002] [2021-04-09 13:04:35.784] Record creation> Generating metadata
[0002] Metadata file saved
[0002] Data successfully created from : EMS_DM.OL-datamapper
[0002] Plugin Execute Data Mapping completed successfully - 13:04:35 (elapsed time: 00:00:00.306)

[0003] Starting plugin Create Print Content - 13:04:35
[0003] Default Server IP address: localhost
[0003] Parsed Default Server IP address: localhost
[0003] Default Server Port: 9340
[0003] Parsed Default Server Port: 9340
[0003] Source data is MetaData
[0003] Creating the rest client
[0003] Cached version not available, attempting to upload file.
[0003] Template C:\ProgramData\Objectif Lune\PlanetPress Workflow 8\PlanetPress Watch\OLConnect\Template\EMS OL_T.OL-template uploaded to server
[0003] Starting content creation operation…
[0003] [2021-04-09 13:04:35.967] Print content creation> Retrieving results
[0003] Content created from template and metadata
[0003] Metadata file saved
[0003] Content successfully created from : EMS OL_T.OL-template
[0003] Plugin Create Print Content completed successfully - 13:04:39 (elapsed time: 00:00:03.430)

[0004] Starting plugin Create Job - 13:04:39
[0004] Default Server IP address: localhost
[0004] Parsed Default Server IP address: localhost
[0004] Default Server Port: 9340
[0004] Parsed Default Server Port: 9340
[0004] Create the rest client
[0004] Creating Job…
[0004] Cached version not available, attempting to upload file.
[0004] Starting job creation operation…
[0004] [2021-04-09 13:04:39.522] Job creation> Retrieving results
[0004] Metadata file saved
[0004] Job successfully created from : EMS_job-preset.OL-jobpreset
[0004] Plugin Create Job completed successfully - 13:04:39 (elapsed time: 00:00:00.207)

[0005] Starting plugin Create Output - 13:04:39
[0005] Default Server IP address: localhost
[0005] Parsed Default Server IP address: localhost
[0005] Default Server Port: 9340
[0005] Parsed Default Server Port: 9340
[0005] Cached version not available, attempting to upload file.
[0005] Starting output creation operation…
[0005] Output created and stored in file “vgerAD18466.dat”
[0005] Output successfully created from : EMS pdf.OL-outputpreset
[0005] Plugin Create Output completed successfully - 13:04:40 (elapsed time: 00:00:01.103)

[0006] Starting plugin Send To Folder - 13:04:41
[0006] Path: c:\out
[0006] Parsed path: c:\out
[0006] Filename: %f
[0006] Parsed filename: debugAD172D2.dat
[0006] File sent : c:\out\debugAD172D2.dat, size: 35288 bytes
[0006] Plugin Send To Folder completed successfully - 13:04:41 (elapsed time: 00:00:00.001)

WPROC: EMS_JOB (thread id: 7916) complete - 13:04:41 (elapsed time: 00:00:05.940)

Start debugging.
Using schedule for EMS_JOB

WPROC: EMS_JOB (thread id: 6492) - 13:10:26

[0003] Starting plugin Create Print Content - 13:10:26
[0003] Default Server IP address: localhost
[0003] Parsed Default Server IP address: localhost
[0003] Default Server Port: 9340
[0003] Parsed Default Server Port: 9340
[0003] Source data is MetaData
[0003] W3001 : Error while executing plugin: W3886 : Metadata file to append: “C:\ProgramData\Objectif Lune\PlanetPress Workflow 8\PlanetPress Watch\Debug\debugAD6CDBB.dat.meta”, was not found
[0003] Create Print Content: W1603 : Plugin failed - 13:10:26 (elapsed time: 00:00:00.001)

[0004] Starting plugin Create Job - 13:10:26
[0004] W3001 : Error while executing plugin: W3886 : Metadata file to append: “C:\ProgramData\Objectif Lune\PlanetPress Workflow 8\PlanetPress Watch\Debug\debugAD6CDBB.dat.meta”, was not found
[0004] Create Job: W1603 : Plugin failed - 13:10:26 (elapsed time: 00:00:00.000)

[0005] Starting plugin Create Output - 13:10:26
[0005] Default Server IP address: localhost
[0005] Parsed Default Server IP address: localhost
[0005] Default Server Port: 9340
[0005] Parsed Default Server Port: 9340
[0005] W3001 : Error while executing plugin: W3886 : Metadata file to append: “%s”, was not found
[0005] Create Output: W1603 : Plugin failed - 13:10:26 (elapsed time: 00:00:00.002)

[0006] Starting plugin Send To Folder - 13:10:26
[0006] Path: c:\out
[0006] Parsed path: c:\out
[0006] Filename: %f
[0006] Parsed filename: debugAD6CDBB.dat
[0006] File sent : c:\out\debugAD6CDBB.dat, size: 6482 bytes
[0006] Plugin Send To Folder completed successfully - 13:10:26 (elapsed time: 00:00:00.001)

WPROC: EMS_JOB (thread id: 6492) complete - 13:10:27 (elapsed time: 00:00:00.845)

Start debugging.
Using schedule for EMS_JOB

WPROC: EMS_JOB (thread id: 13660) - 13:10:33

[0002] Starting plugin Execute Data Mapping - 13:10:33
[0002] Default Server IP address: localhost
[0002] Parsed Default Server IP address: localhost
[0002] Default Server Port: 9340
[0002] Parsed Default Server Port: 9340
[0002] Sending file data source…
[0002] File Data Source ID: 64868914
[0002] Sending data mapping command…
[0002] Using cached configuration file (id = 64747492).
[0002] Starting data mapping operation…
[0002] [2021-04-09 13:10:33.732] Record creation> Retrieving results
[0002] [2021-04-09 13:10:33.963] Record creation> Generating metadata
[0002] Metadata file saved
[0002] Data successfully created from : EMS_DM.OL-datamapper
[0002] Plugin Execute Data Mapping completed successfully - 13:10:33 (elapsed time: 00:00:00.259)

[0003] Starting plugin Create Print Content - 13:10:34
[0003] Default Server IP address: localhost
[0003] Parsed Default Server IP address: localhost
[0003] Default Server Port: 9340
[0003] Parsed Default Server Port: 9340
[0003] Source data is MetaData
[0003] Creating the rest client
[0003] Using cached file (id = 64747493).
[0003] Starting content creation operation…
[0003] [2021-04-09 13:10:34.124] Print content creation> Retrieving results
[0003] Content created from template and metadata
[0003] Metadata file saved
[0003] Content successfully created from : EMS OL_T.OL-template
[0003] Plugin Create Print Content completed successfully - 13:10:37 (elapsed time: 00:00:03.260)

[0004] Starting plugin Create Job - 13:10:37
[0004] Default Server IP address: localhost
[0004] Parsed Default Server IP address: localhost
[0004] Default Server Port: 9340
[0004] Parsed Default Server Port: 9340
[0004] Create the rest client
[0004] Creating Job…
[0004] Using cached config file (id = 64747495).
[0004] Starting job creation operation…
[0004] [2021-04-09 13:10:37.470] Job creation> Retrieving results
[0004] Metadata file saved
[0004] Job successfully created from : EMS_job-preset.OL-jobpreset
[0004] Plugin Create Job completed successfully - 13:10:37 (elapsed time: 00:00:00.236)

[0005] Starting plugin Create Output - 13:10:37
[0005] Default Server IP address: localhost
[0005] Parsed Default Server IP address: localhost
[0005] Default Server Port: 9340
[0005] Parsed Default Server Port: 9340
[0005] Using cached config file (id = 64868912).
[0005] Starting output creation operation…
[0005] Output created and stored in file “vgerAD6FA97.dat”
[0005] Output successfully created from : EMS pdf.OL-outputpreset
[0005] Plugin Create Output completed successfully - 13:10:39 (elapsed time: 00:00:01.217)

[0006] Starting plugin Send To Folder - 13:10:39
[0006] Path: c:\out
[0006] Parsed path: c:\out
[0006] Filename: %f
[0006] Parsed filename: debugAD6EA0D.dat
[0006] File sent : c:\out\debugAD6EA0D.dat, size: 35288 bytes
[0006] Plugin Send To Folder completed successfully - 13:10:39 (elapsed time: 00:00:00.001)

WPROC: EMS_JOB (thread id: 13660) complete - 13:10:39 (elapsed time: 00:00:05.812)

Start debugging.
Using schedule for EMS_JOB

WPROC: EMS_JOB (thread id: 13472) - 13:12:34

Please wait while the current task finishes processing…
[0002] W1602 : Stopping execution of process
WPROC: EMS_JOB (thread id: 13472) complete - 13:19:54 (elapsed time: 00:07:20.087)

Start debugging.
Using schedule for EMS_JOB

WPROC: EMS_JOB (thread id: 13368) - 13:20:10

Might be just the way you posted the logs but seems like everytime you have the error, you seem to start the process on the Create Print Content plugin…no?

yes! cause it stayed endless at ‘‘Execute Data Mapper’’. even if it ignored the WindQue input and runs through i still have same error. I have watched the videos well and i think where am having issue is ‘‘metadata sample file’’ to attached in the Data Selector. how do i generate metadata or where can i find metadata to attached to the data selector. Data Emulation is also a big issue for me. please help out.
Thank you very much.

Since from the logs you have shown there are instance where it worked, I doubt the problem is with the metadata.
You can’t by pass the Datamapper because it is too long. You should try with a minimized version of your data (1-10 records) to setup everything properly and then you run LIVE test.

Did you try with the exact same data you used to build your project (the one in your Datamapper from the Designer)?

Thank u am grateful. I use the same data mapper. I reduced it to 20 records after reading the documentaton u sent. But the format of my data mapper is .csv of 10 columns. Why am suspecting metadata is that on the error message it says “metadata not FOUND”. i will be glad if u would help me out. Thank u

At this point it is best for you to open a technical support ticket via our website. This way, a technician will be able to remote at your site, see you complete setting and propose a resolution.