Table of Contents

PDM Tasks

Use a PDMShell task to run a script through the PDM Task List, on a task host, from a workflow transition, or on a schedule. Configure it in SOLIDWORKS PDM Administration → Tasks.

Create a task

  1. Create a task and select PDMShell on its Add-in page.
  2. Choose the task hosts on Execution Method. Install PDMShell on each host.
  3. Add the script on PDMShell Script.
  4. Configure inputs, permissions and an optional Explorer menu command as described below.
  5. Choose OK to save the task properties.

Select the PDMShell add-in for a PDM task

The standard PDM pages control execution hosts, scheduling, task permissions, and success/error notifications. The PDMShell pages configure the script and its launch options.

PDMShell Script page

PDMShell Script page with an editable script, import buttons, linking, affected documents and test buttons

Enter the script directly, choose Import file… for a .pdmshell or plain-text file, or choose Import vault script… for a saved vault script. Encrypted .pdmshell files and Unicode text are supported. Save task properties after making changes.

An unlinked script is an editable copy stored in this task. Editing it does not change the original file or vault script. A linked script shows a read-only preview; edit its source in standalone PDMShell, or turn linking off to edit the stored copy.

The screenshot shows a task that moves matching PDFs, starts another PDM task, and writes a log. Its paths and task name are examples; use the folders and tasks configured in your vault.

Choose a saved vault script

Import saved vault script dialog with Search, a script list, a read-only preview and Import copy

Use Search to filter the list, select a script, review its preview, then choose Import copy. Confirm replacement if requested. Cancel leaves the task unchanged.

Importing creates a snapshot. The message in this picker describes that initial copy; to follow later edits, enable the link option after importing.

Link to vault script (use latest saved version) checkbox

After importing a saved vault script, enable Link to vault script (use latest saved version) and save task properties. Each run loads the latest saved code and layout, including changes saved after the task was queued. The preview shows the last imported copy.

Affected documents, task inputs, permissions and error handling remain configured on the task. Linking does not replace these settings.

Turn linking off to use the stored copy again. Importing a standalone file clears the link. If the linked script is renamed, select it again; if it is missing, disabled or unavailable, the task reports an error instead of running an old copy.

Affected documents

Setting What to choose
File extensions Enter * for all files, or extensions such as sldprt;sldasm;slddrw.
Also run on folders Enable when your script should process selected folders as task items.
Do not use optimized script execution Enable to finish the entire script for one item before starting the next. Every line repeats for each item.

Sequential execution is used when either the task's Do not use optimized script execution option or the task host user's corresponding global setting is enabled. Otherwise, optimized execution is used.

Test the script

Test With File and Test With Folder run the script against your chosen item. Folder tests use the selected folder.

Warning

These buttons execute the script and can change files or vault data. Use a controlled test item. They are not a preview.

Task inputs

Task inputs settings with Variable, Prompt, Default value and Required columns

Add one row for each answer you need when the task launches:

Column Purpose
Variable The name used in the script, without ${task.}.
Prompt The label shown to the person launching the task.
Default value Initial text shown in the input field. Leave blank if no default is needed.
Required Prevents continuing with a blank answer.

In the screenshot, the variable is TaskDefinedVariable, its default is 0, and Required is checked. Read the answer in your script with:

setglobal -name LaunchAnswer -value "${task.TaskDefinedVariable}"

You can also use an answer directly in a command value, such as -value "${task.TaskDefinedVariable}". Task answers use ${task.Name}; $(VariableName) still reads PDM card variables.

When the task launches, one dialog shows the task name and all configured prompts. Fields accept multiple lines with Enter. Choose Continue to accept the answers or Cancel to cancel the launch.

Answers stay with that task instance, including when another computer runs it. All selected items in the same task use those answers. Defaults and answers are literal text; expressions inside them are not executed.

Variable names are case-insensitive. Start with a letter or underscore, then use letters, digits or underscores. Delete a row to remove an input and choose OK to save.

For unattended runs without collected answers, supply defaults. A required input with no value reports an error rather than opening a dialog on the task host. Tasks with no input rows do not show an input dialog.

To read a project folder's existing Title instead of asking the user, use folderVariable.

Error handling

Expand Error handling on the Script page to choose how failures affect the task, then save task properties.

Expanded Error handling section with all three options unchecked

Setting Behavior
Stop script after a non-ignored error Off: continue after an error, but finish the task as Failed. On: stop after the failing command.
Ignore checkout already owned by this user on this computer Existing-checkout compatibility option. Checkout already skips a file owned by the executing user on the same computer, even when this option is off.
Ignore missing checkout targets Treat a checkout target missing from the vault as a warning. This does not ignore missing files or dependencies in other commands.

All three options are unchecked in the screenshot. Continuing after an error does not turn the task into a success: a later successful command does not erase an earlier failure.

Checkouts owned by another user or computer, permissions failures, connection failures and unknown errors are not ignored by these options. Cancellation stops the task. Changes already made are not rolled back.

The checkout owner is the user running the task on its host, which may differ from the person and computer that launched it.

Command Menu page

Command Menu settings with menu label, help text and Show Command in File Explorer

Field Purpose
Command Menu The label users see in the PDM Explorer menu. Replace the example New Task with a descriptive name.
Command Text Short help text explaining what the command does.
Show Command in File Explorer Makes the task available from the PDM right-click menu.

The visibility checkbox is off in the screenshot. Leave it off when the task should be launched only through a workflow transition, schedule or the Task List.

PDMShell Permissions page

PDMShell Permissions page showing Users and Groups tabs and Permit checkboxes

Select Users or Groups, then check Permit for the people who should be allowed to launch this task, including from workflow transitions. Choose OK to save.

If no users or groups are selected, this page adds no extra restriction; standard PDM permissions still apply. Once you select entries, the launcher must be a permitted user or belong to a permitted group. The screenshot shows no entries selected.

This page is separate from PDM's standard Permissions page. Configure both: standard PDM permissions still govern access to the task, and the script must have the permissions needed for its vault operations.

Task progress

The task's progress message shows the current command. A successful run finishes with Completed. Failed and cancelled tasks keep their corresponding status.