Site Translation Underway
Our translation team is diligently working to provide a fully localized experience.
If you spot any English text, rest assured we're on it—thank you for your understanding.
Contact Us
SOLIDWORKS PDMProfessional is filled with features to ease the burden of meticulous documentation and data entry. However, few tools are useful without proper understanding, configuration, and implementation. To that end, this article discusses the purpose, setup, and troubleshooting of XML import/export rules in PDM.
What are XML Import/Export Rules and What Do They Do?
Before jumping into the subject, it is important to understand the ideas behind XML import/export. XML import and export rules in SOLIDWORKS PDM Professional are a feature designed to automate the transfer of data between the SOLIDWORKS PDM vault and external systems.
Export:As the name implies, Export rules are used to automatically generate XML files containing data, specifically Bills of Materials (BOMs), for use outside of your SOLIDWORKS PDM vault. These XML files can then be read by other systems, such as Enterprise Resource Planning (ERP) or Product Lifecycle Management (PLM) systems.
Import: Meanwhile, Import rules are used to import data, via variable values, to be associated with specific files within your SOLIDWORKS PDM vault from XML files.
Understandably, you may still be asking why this is useful. As mentioned above, manually “syncing” this data often comes down to manual data entry, which leads to human error in the data or bottlenecks in the import/export process. If we can’t get the two systems to work together directly via some kind of software connection, allowing the two systems to pass “notes” (XML files) is the next best option.
Example Use Cases
It’s easy to say, “You can use import and export rules to move XML data in and out of PDM”, but that doesn’t do much to provide a real idea of the benefit. To help with that, below are two of the most common scenarios we see with XML rules. We’ll revisit these scenarios as we go through the steps involved in setting them up.
Scenario 1
Exports- Sending part or assembly data to ERP systems when a design is finalized
ERP systems often need detailed assembly or part data, so it may be part of your workflow to take the properties and data from a part or assembly after approval and pass it to the ERP as an XML file. This export can be triggered through transition actions.
Scenario 2
Imports- Migrating files into PDM
Let us assume you have files that were created outside of your PDM vault and, as a result, are missing information from their data card. If that data was tracked somewhere else, and can be reformatted into an appropriate XML file, the information could be imported into PDM via an XML rule, and the values on the data cards can be automatically updated on their next transition.
Creating the Rule
After deciding how you’re going to use the XML import/export rules, the next question becomes: How do you set one up?
Open the PDM Administration Tool and expand Data Export/Import. Right-click eitherExport RulesorImport Rules>New Export/Import Rule.
Import Rules Fields
Rule Name
Frequency to check import folder: Define how often (in minutes) the system will scan the designated folder for new files to import into the system.
Setting this too frequently may bog down your system. We generally recommend 5-10 minute intervals.
Import from Folder:The folder where the files you want to import will be stored. This is generally a folder outside of the vault. You can paste a path directly into the field or use the … button to browse to a location of your choice.
This must be a location accessible by the account running PDM’s database server service (not the SQL service). Full read/write access will be needed.
If using a network location, use UNC paths as opposed to a “mapped drive”.
Variable Alias Set:If you have created any variable alias sets, this is where you would select them (we’ll cover what these are a bit later). If your import data has the same data labels/headers, you can ignore this in favor ofDo not use an alias set.
Export Rules fields
Rule Name
Output XML–files to folder: The folder where the files created by the export rule will be stored. This is generally a folder outside of the vault. You can paste a path directly into the field or use the … button to browse to a location of your choice.
This must be a location accessible by the account running PDM’s database server service (not the SQL service). Full read/write access will be needed.
Note: If using a network location, use UNC paths as opposed to a “mapped drive”.
Output XML-file name: You can use static text and/or dynamic variables (using the > button) based on the source file to make a unique name for each file.
If a file with the same name already exists, the system will automatically append a counter at the end of the name to ensure unique values.
Don’t include the .XML extension in the output. The system adds this automatically.
Type of data to export:
CAD BOM: Generates an XML file for drawing or assembly files that contain a CAD BOM.
The BOM layout, not the export rule, determines the variables, configurations, and references to include or exclude in the XML data.
Your workflow transition must use theRun for filesoption in the action to trigger this properly.
Computed BOM: Exports data from the computed BOM. Generates an XML file for all files, provided a BOM is defined.
Your workflow transition must use theRun for filesoption in the action to trigger this properly.
To export cut lists or item BOMS, selectComputed BOMas the type, and then select a computed BOM template set up to include cut lists or items in theBOM to exportdropdown below.
Named BOM: Exports named BOMs. As with CAD BOMs, the variables are defined by the BOM template layout and not the rule itself.
Your workflow transition must use theRun for named BOMsoption in the action to trigger this properly.
Export BOM in table format: This formats the output in a flat table structure that matches the BOM as seen via the UI. If unchecked, data is formatted hierarchically, like an assembly tree.
CAD and Named BOMs are always formatted in tables and cannot be changed.
Export ONLY activated BOMs: The export will only run if a CAD or Computed BOM is marked “activated”.
(These three tabs are only available when you select Computed BOMS.)
Variables tab
Bill of Materials to export: Choose which template for BOMs you’d like to use. These are created in the “Bills of Materials” node in the admin tool.
Variable used to ID a file: The unique value used to identify a file. It’s generally best to use the defaultSOLIDWORKS PDMFile ID, thoughDocument Number,FileName, etc., work well too.
Alias set to use in XML-file: If the data being output requires a translation of the Data labels/headers, select the appropriate alias set.
Configurations tab: This lets you select which configurations you’d like to include in the export.
File Reference tab: This allows you to select which type and what versions of references you’d like to include.
Variable Alias Sets
If your ERP or other system requires specific field names for values you have mapped on your data card, but the variable name and the field name don’t match, you can use an Alias Set to change the name in the exported XML file to match. You can map specific variables in PDM to their equivalent field name in the receiving system by selecting the variables from the left and then entering their Alias on the right.
Alias sets are not required, and if none are chosen, the system just exports variable names as-is.
Triggering Import/Export Rules
With the rules set up, we’ll want to select the transition these rules are triggered by. Once decided:
From thePDM Administrationtool, expand Workflows and double-click to edit the desired workflow.
Click into the transition you’d like an XML rule to run during.
Go to theActionstab >AddAction.
SelectExport Data to XMLorImport data from XMLfrom theTypedropdown.
ForExport Data to XML,select the export rule.
ForImport Data to XML,select the file name to import from.
Note: Unless you have a specific reason to call out a specific file name (such as calling data from different files for different transitions), you can leave this as the wild card value; it defaults to:*
Finally, with our rules set and their actions in place, we should be able to reap the rewards of our labors. Our expectations for the Export rule are somewhat less involved than the Import rule. If working properly, the XML export is triggered by the file transition, and the XML file is placed in the expected folder, with the expected name and details inside.
When the import is run, however, the steps are a bit more complex. First, the formatted XML is placed in the expected folder for processing. Generally, the Database server service picks up the file within 60 seconds. The Database server service loads the data in from the XML file into the Database and waits to be called upon. When the part, assembly, or drawing is pushed through the target transition with theImport data from XMLaction, it triggers the imported data to write to the Database record for that file or those files.
XML Formatting for Imports
While the example above shows how this data can be applied to model/drawing files, it isn’t the only function that can be taken care of via import. In this case, the XML file formatting determines what the file is being used for.
You can view a list of the example import files and their formats in the SWPDMClient/Support/ERP folder in the installation files under “…\SOLIDWORKS Downloads\SOLIDWORKS 20XX SPXX\SWPDMClient\Support\ERP”.
SOLIDWORKS also provides a set of general rules to help us understand these example XML files.
The encoding specified in the XML header must be the encoding that file is saved in.
All IDs must be unique (per type) in each XML file (i.e., no two files can share an ID); however, files and folders can share an ID as they are not the same type.
All IDs must be greater than 0. All values 1 and above are valid, but not 0 (zero).
Attribute values are considered text and must be in double quotes (i.e., attributes that are alpha-numeric must be in double quotes:id = ashould beid = “a”,id= 3should beid = “3”).
Some special characters are reserved for XML formatting (also calledXML reserved characters) and cannot be used. They include the following (in bold):< > & ‘ “. They can still be used by replacing them with the appropriate substitute:
<becomes<
> becomes>
&becomes&
‘becomes&apos
“becomes"
The XML file must include a DTD declaration. This is a way for the file to declare what type it is, hence “DTD” or Document Type Declaration. This is generally satisfied within the first or second line of the XML file, using a DOCTYPE callout.
Troubleshooting
Below are some of the more common issues that you can run into when using import/export rules, and steps you can take to solve them.
Imports are Failing
What does this look like? Once imported, files should disappear from the import folder. If they remain past the set polling interval, the rule may be failing.
Steps to Take:
Verify theSOLIDWORKS PDM Database Serverservice is running.
Verify thePDM Database Serverservice has access to the import folder.
If the import folder is on a network location, try moving it to a location on the server running thePDM Database Serverservice instead. Be sure to change the import rule to look for the new location.
If a network location is necessary, please be sure to use a UNC path instead of a mapped network drive.
Verify the XML files are not read-only.
Verify that the login account for thePDM Database Serverservice has read and write access to the target folder.
Check Event Viewer logs on the server hosting the database service for related errors. (Event Viewer>Windows Logs>Application).
Verify the XML file is correctly formatted.
XML File Names Missing Variable Values
What does this look like?Files export as:
.XML, 001.XML, 002.XML, etc.
Output file name set to [variable1]-[variable2][counter].XML.
Some files appear to be named correctly, others appear as “variable1-counter.XML”.
Steps to take:
Verify theOutput XML file name.
The issue may be that the output name is set to something like [variable][counter].XML.
In this case, these files do not have a value for the variable used in the name, so only the counter is exported.
Alternatively, the variable field does not exist on all files.
Special Characters Are Not Recognized when Importing XML
What does this look like?File names and variables containing special characters may show up incorrectly or not at all.
This can be caused by the XML header using the wrong encoding (e.g., UTF-8). The encoding listed in the header must match the encoding the file was saved under.
Steps to take:
Open the file in Notepad and check the encoding in the file header. If needed, correct the encoding listed in the header and resave the file with that encoding.
Error: Could not find any variable value that matches node [document] idattribute
What does this look like?Specific values fail to import, and an error appears in the Windows Application logs (Event Viewer>Windows Logs>Application) with references like:
Error(s) occurred when starting the data import for database 'cex'.
Error: 0x0 Description: The method was successfully executed.
Failed importing document attributes from node (#1) in file ‘C:\XML\ImportValues.XML’.
Could not find any variable value ‘S-2014-0034’ that matches node 's ‘idattribute’ ‘DocNumber’ (VariableID 142).
Error: 0x800402A6. Description: The specified variable does not exist.’
In order for the import to locate and update the variable values for specific files, it needs to be able to identify/locate the file. In the XML file (just like in the XML export), there is a specific label that tells the system which value to use. If that value is not found in the PDM database on any file, this error should appear.
This can happen if the import XML has the wrong identification data for a given file (e.g., “1234” instead of “1233”), or if it is looking for a value labeled “partnum” but the variable is “partnumber”, etc. Further, this can be a problem with the formatting of the XML file itself. If the value being used to match files is a variable, pdmweid should be set to 0. Or, if the value is configuration-specific, the value of “idcfgname” should be set.
Steps to take:
Check the error message for the value that was not matched.
This issue may occur with several files at once. Compare which fields are mentioned to narrow down the actual cause.
Verify which identifier is being used and that the value for the target file matches the value in the XML.
Verify which variable is used to match the XML data to the files in the vault and whether the pdmweid value is set correctly in the XML file.
Check if the value is configuration-specific and whether the “idcfgname” field is blank, or if it calls out a specific configuration.
Error: The data import/export item was not found in the database
What does this look like?If PDM encounters a problem processing the BOM during the XML export, it will produce an error inEvent Viewer>Windows Logs>Application:Failed to process export batches in database [Database name].
The error may happen multiple times as the system tries to process the file and fails each time. You will need to find the file causing the problem.
Steps to take:
Resolving this error usually involves editing your SQL database. Reach out toTechnical Supportfor help in addressing this safely.
The Database Service isn’t Running
What does this look like?XML import/export rules are powered by the PDM database service. The database service also powers a number of other things, so if your XML rules are failing, it may be worth looking for other signs as well:
Notifications aren’t sending (both SMTP and database type notifications would fail).
View Updates: Automatic refreshing of a user’s local vault view to automatically display updates from other users (new files added, variable updates, check-ins/outs) in the same folder without having to refresh File Explorer.
Card list updates: Cards making use of an SQL list may load an older version of the list or fail to load at all.
Cold storage.
On-demand replication would still work, but scheduled replication would fail.
Steps to take:
From the WindowsServicesapplication, locate theSOLIDWORKS PDM Database ServerService.
Verify this is running and, if it is not, try to start it.
Once started, it should cycle through the queue of messages and exports built up since the last time it ran. Depending on the queue, it could take some time.
If it does not start, there may be a deeper issue. In which case, reach out toTechnical Support.
If the service itself is already running, you will want to verify that there are no logs mentioning issues logging into the SQL server. To check these, openEvent Viewer>Windows Logs>Application.
If there are any errors found, you may see them running periodically (generally 1-2 times every minute, minimum). Often, these errors will say something along the lines of The Owner SID on a Per-user Subscription doesn’t exist.
If this is the case, the next step is to verify the SQL username and password used for both the Archive server service and (more importantly in this case) the Database server service.
If, for any reason, the password is incorrect because the SQL username and password have been lost, we have a guide onresetting the SA credentials.
Final Thoughts
XML Import and Export rules are a versatile way to migrate data in and out ofSOLIDWORKS PDM. In addition to the steps in this blog, successful setup and use of this tool can often take some time and trial and error. As such, it’s best to implement this under the guidance of an experienced PDM administrator.
If GoEngineer is your reseller and you have any questions, please reach out to ourSupport teamfor assistance!
24 Tips to Master SOLIDWORKS PDM
SHORTCUTS ⋅ SEARCHING ⋅ PDM ADD-IN
24 of our expert tips to help you master using SOLIDWORKS PDM. Improve performance, find files faster, and work like a pro.
Get our wide array of technical resources delivered right to your inbox.
Unsubscribe at any time.
×
Alert
As of June 2022, Microsoft will no longer support Internet Explorer. To ensure your browsing experience is not interrupted please update to Microsoft Edge.