Migrating from another platform to ServiceNow can be challenging, especially when you need to import large amounts of historical data. One of the biggest challenges in this process is moving attachment files and keeping them with the proper record. Fortunately, ServiceNow provides an attachment REST API that can be leveraged to move our attached files back where they need to be. All you need is a unique identifier from your source records on your target table and a little magic concocted by the Pathways team.
The attached .cmd file (Download Here) can be used to load attachments from a local machine into ServiceNow via the Attachment API.Â
The batch file is written to use a .csv file that you create from your target table to match up each ServiceNow record sys_id with another field on the record that acts as a unique identifier for your legacy system. If it then finds a folder that matches the legacy identifier, it will upload any files in that folder as attachments to the target record.
All you need to do is create a source CSV file and plug in some variables!
For each step I will provide an example. In the example use case, we are importing attachments from an imaginary system called HelpDesk. In ServiceNow, we’ve created a custom field called u_helpdesk_id, and when we imported our legacy data, we populated that field with the unique identifier from that system.
Loading Attachments to ServiceNow using Windows Batch ScriptingPre-Requisites:
Records must already be imported to ServiceNow prior to the attachment load
Records must have a field that holds the unique identifier from the legacy system
Attachments must be in a folder structure where each folder name matches the legacy system’s unique identifier of the attachments that it holds
Access to a username and password of a ServiceNow account that can write to the table needed (preferably admin)
cURLinstalled on your local computer (often installed by default in modern Windows)
Example:
Here is an example of how your folders should be set up. Each folder is named for the legacy unique identifier, and inside of each folder are the attachments for that record.
Instructions to Load Attachments:
Step 1: Extract a CSV of your records from ServiceNow
You’ll need to extract your records with the sys ID using the “export fields all” URL. Replace the text bracketed by <> with your instance, table and field that holds the legacy unique identifier. https://<your-instance>.service-now.com/<table>_list.do?sysparm_query=<legacy_id_field>ISNOTEMPTY&CSV&sysparm_default_export_fields=all Paste this into your browser bar, and it will automatically download the records with all fields, including the sys_id, to your default download location.
Example:
In our example, our target table is Incident, and our custom legacy unique identifier field is u_helpdesk_id, so our url will be this:
Once you have located the exported .csv file, open it in Excel or your favorite editor.
Remove all columns except sys_id and your identifier column (u_helpdesk_id in this example)
Make sure that sys_ids are in column A and your legacy identifier is in column B
Remove the header rows
Save (make sure to keep in csv format) in a convenient location such as C:\temp\import. Note:make sure there are no spaces in your path.
Make sure to close out of the file!
You are now ready to add your inputs to the script!
Example:
We’ve downloaded our csv and edited as above, so this is what it looks like now:
Step 3: Download and edit the batch file
Click here to download the batch file <link loadAttachmentsToServiceNow.cmd>.
After unzipping, right-click on the .cmd file and select “Edit”
At the top of the file you will see a section called “EDIT VARIABLES HERE”. Edit the variables as needed. For example:
set instance=demoinstance
set targetTable=incident
set rootFolder=C:\temp\import
set pathCSV=C:\temp\exported_file.csv
set LOGFILE=C:\temp\import_log.txt
set username=admin
set password=admin
Keeping the recommended paths and file names will give you the best results!
Note: If your paths above have spaces in them, move your files to a location without spaces, or the script will fail!
Make sure to save the file once you are done editing!
Step 4: Test
Don’t skip this step!
Once we let this script rip, it will start uploading to records. You want to first make sure that it’s behaving correctly before you let it loose on your instance. And as always, test first in a sub-prod instance!
The .cmd file as downloaded has the command that uploads the files commented out. Check that this is the case by searching for “curl” in the file. You should see that it is commented out with the keyword “rem”.
Locate the .cmd file in the explorer. Double-click the file to run it. Check the location of the log file and validate that the script is matching up your records properly. Edit your .cmd file and your import csv and rerun as many times as you need to be sure that everything is matching up correctly.
Example:
Here you can see some examples from our sample data. We can check these against the sys_ids of the records in ServiceNow, to make sure that everything matches up correctly.
Step 5: Upload those attachments!
At this point, you’ve tested thoroughly and you’re ready to reap the rewards!
Edit the script to remove the “rem” in front of that curl command.
It should now look like this:
Save the .cmd file, then double-click on the file to run it. You should be able to watch as the attachments get uploaded. As it goes, it will log the API responses to your log file.
Note: If you get the error message “The system cannot find the file <path>.csv.” but the path looks correct, make sure you don’t have the file still open in Excel!
Example:
We’ve run the file and watched our uploads, and now it’s complete!
Effective Testing Strategies for ServiceNow Attachment MigrationStep 6: Validate
First, make sure to check your log file to see the behind-the-scenes action. Here you will see any errors that occurred. You may need to go back and edit your variables if you encounter problems. In the example below, you can see that there was an issue with the username/password
Example:
In this example, you can see that the username/password combination didn’t work!
You can validate the uploads by going to your target table and opening your records. You can also check the [sys_attachment] table to see the attachments appear as they come in. Filter by the target table field to see the ones you are looking for!
We hope this has helped make the migration process a little smoother!
While the above technical tip has been provided with care and consideration, it’s important to acknowledge that individual circumstances may vary. Always ensure compatibility and feasibility within your specific ServiceNow environment before implementing any suggestions. Additionally, back up your data and proceed with caution when making any changes to your instance or workflows.
As with any change in ServiceNow, make sure you test any changes prior to moving to production.
Learn how Pathways Consulting Group can work for you
Connect with a ServiceNow Expert
Contact Us
servicenow export attachments, servicenow create attachment from script, servicenow rest api attachment example, servicenow rest api attachment, attachment service
Preparing for ServiceNow Data Migration
Before beginning the attachment migration process, it's crucial to ensure that the necessary prerequisites are in place. This includes verifying that the records have already been imported into ServiceNow and that a unique identifier field is available to map the attachments to the corresponding records.
Additionally, having access to a ServiceNow account with appropriate permissions to write to the necessary table is essential. Ensuring that the folder structure aligns with the legacy system's unique identifiers will streamline the attachment loading process.
Extracting and Formatting the CSV File
The first step in the attachment migration process is to extract a CSV file containing the necessary data from ServiceNow. This file should include the sys_id and the unique identifier field from the legacy system, which will be used to match the attachments to the corresponding records.
Once the CSV file is obtained, it should be formatted by removing any unnecessary columns and ensuring that the sys_id and unique identifier field are in the correct format.
Customizing the Batch Script
The provided batch script can be customized to fit the specific requirements of the migration process. This includes updating the script variables, such as the ServiceNow instance, target table, file paths, and user credentials, to match the details of the current implementation.
It's important to ensure that the file paths do not contain any spaces, as this can cause issues with the script execution.
Validating the Attachment Migration
After running the batch script, it's crucial to validate the attachment migration process. This can be done by checking the log file for any errors or issues that may have occurred during the upload process.
Additionally, it's recommended to manually verify a sample of the uploaded attachments to ensure that they have been successfully imported into ServiceNow and are associated with the correct records.
risk, it service management, organization, workflow, managed services, servicenow, regulatory compliance, asset management, infrastructure, configuration management database, automation, software asset management, configuration management, cloud computing, customer, asset, customer service, productivity, governance, it infrastructure, analytics, customer experience, efficiency, mobile app, innovation, field service management, digital transformation, audit, risk management, return on investment, knowledge, software as a service, project management, visibility, operational efficiency, retail, system, consultant, mobile app development, architecture, data migration, custom app development, itsm, servicenow managed services, implementation services, servicenow ecosystem, servicenow custom app, servicenow implementation services, service catalog, servicenow solutions, servicenow service, customer service management, service now consultant, servicenow consultancy, servicenow consultant, servicenow implementation partner, supply chain, implementation, customer satisfaction, database, user experience, server, leverage, knowledge management, devops, ecosystem, scalability, user experience design, business process, provisioning, enterprise software, data model, landscape, itil, competitive advantage, customer engagement, microsoft dynamics 365, workforce, empowerment, expert, cyber resilience, health care, information technology, css, logistics, culture, chatbot, patient, outsourcing, strategy, vulnerability, onboarding, consumer, client, change management, revenue, document, policy, inventory, nursing, therapy, leadership, custom solutions, research, accounting, email address, executive search, mentorship, strategic planning, human resources, employment, medical, pathways consulting, leadership development, continuing education, nurse, mission, nursing excellence, financial planning, pathway, understanding, pain, nursing home, training, certification, accounts payable, release, servicenow itsm, servicenow consulting, servicenow consulting services, procurement, methodology, machine learning, transparency, cloud management, energy, intelligence, workflows, order management, implementation partner, service level management, professional services, enable, servicenow implementation, service management, consulting firms, application management services, servicenow platform, servicenow consultants, sciencesoft
Frequently Asked Questions
What services does ServiceNow provide?
ServiceNow provides a range of IT and enterprise management services, including service management, operations management, business management, and employee workflows, all delivered through its cloud-based platform.
What does a ServiceNow consultant need to know?
A ServiceNow consultant needs to have a deep understanding of the ServiceNow platform, including its capabilities, configuration, and customization options, to effectively design and implement solutions that address the client's specific requirements.
What does a ServiceNow consultant do?
A ServiceNow consultant helps organizations implement, configure, and customize the ServiceNow platform to streamline their IT processes, improve service delivery, and enhance operational efficiency.
Does ServiceNow offer consulting services?
ServiceNow offers consulting services to help organizations leverage the platform's capabilities and achieve their digital transformation goals.
What industries benefit from ServiceNow solutions?
ServiceNow solutions are beneficial for a wide range of industries, including healthcare, finance, IT, manufacturing, and government, as they help streamline workflows, automate processes, and improve service delivery across various business functions.
How does ServiceNow enhance workflow automation?
ServiceNow enhances workflow automation by providing a centralized platform that streamlines and integrates various business processes, enabling efficient task management, real-time data insights, and seamless cross-functional collaboration.
What features distinguish ServiceNow from competitors?
ServiceNow's distinctive features include its low-code development platform, advanced workflow automation, and comprehensive service management capabilities, setting it apart from competitors in the enterprise software market.
How to customize ServiceNow applications effectively?
Customizing ServiceNow applications effectively involves identifying specific business requirements, leveraging the platform's configuration tools, and aligning customizations with best practices to ensure optimal performance and maintainability.
What are common use cases for ServiceNow?
Common use cases for ServiceNow include IT service management, employee onboarding and self-service, asset management, incident and problem management, change management, and workflow automation across various business functions.
How does ServiceNow support IT service management?
ServiceNow supports IT service management by providing a unified platform that automates and streamlines various IT processes, including incident management, change management, and service catalog, to enhance operational efficiency and improve service delivery.
What certifications are beneficial for ServiceNow consultants?
Beneficial certifications for ServiceNow consultants include the ServiceNow Certified System Administrator, ServiceNow Certified Implementation Specialist, and ServiceNow Certified Application Developer certifications, which demonstrate expertise in ServiceNow platform configuration, implementation, and development.
How to ensure ServiceNow implementation success?
Ensuring ServiceNow implementation success requires a strategic approach, effective project management, and collaboration between the ServiceNow partner and the client organization to align the platform with business goals and user needs.
What integrations does ServiceNow support?
ServiceNow supports a wide range of integrations, including popular enterprise applications, cloud services, and legacy systems, enabling seamless data exchange and streamlined workflows across the organization.
How can ServiceNow improve customer service experience?
ServiceNow can improve customer service experience by providing a centralized platform that streamlines processes, automates workflows, and enables real-time tracking and resolution of customer issues, leading to enhanced efficiency and responsiveness.
What are best practices for ServiceNow configuration?
Best practices for ServiceNow configuration include: aligning configuration with business requirements, implementing robust change management processes, leveraging out-of-the-box features, and regularly reviewing and optimizing the configuration to ensure it meets evolving needs.
How does ServiceNow handle data security?
ServiceNow prioritizes data security through robust access controls, encryption, and compliance with industry standards to protect client information.
What roles exist within ServiceNow consulting?
The roles within ServiceNow consulting typically include ServiceNow Architects, ServiceNow Developers, ServiceNow Administrators, ServiceNow Business Analysts, and ServiceNow Project Managers, each with specific responsibilities in implementing and managing ServiceNow solutions.
How to manage ServiceNow updates and upgrades?
Effectively managing ServiceNow updates and upgrades involves careful planning, thorough testing, and seamless deployment to ensure minimal disruption to business operations and maximum benefits from new features and enhancements.
What analytical tools does ServiceNow provide?
ServiceNow provides a range of analytical tools, including built-in dashboards, custom reporting, and advanced analytics capabilities to help organizations gain insights and make data-driven decisions.
How to measure ServiceNow project success?
Measuring ServiceNow project success involves assessing key performance indicators such as user adoption, productivity gains, process improvements, and cost savings achieved through the implementation.
What training is available for ServiceNow users?
Training available for ServiceNow users includes ServiceNow certification courses, instructor-led training, and self-paced online learning modules to enhance their skills and knowledge of the platform.
How does ServiceNow facilitate change management?
ServiceNow facilitates change management by providing a centralized platform to streamline the change process, automate workflows, and track changes across the organization, enabling efficient and controlled implementation of updates and modifications.
What are the costs associated with ServiceNow?
The costs associated with ServiceNow can vary depending on the specific requirements of the organization, such as the number of users, the features and functionalities needed, and any customization or integration requirements.
How to troubleshoot common ServiceNow issues?
Troubleshooting common ServiceNow issues involves identifying the problem, checking logs, testing configurations, and leveraging ServiceNow's knowledge base and community resources to find solutions and resolve the underlying issues.
What is the role of ServiceNow in DevOps?
ServiceNow plays a crucial role in DevOps by providing a centralized platform for streamlining IT workflows, automating processes, and enabling collaboration across development and operations teams, thereby enhancing the efficiency and speed of software delivery.
How to create reports in ServiceNow?
Creating reports in ServiceNow involves accessing the Reports application, configuring report parameters, and selecting desired data fields and filters to generate customized reports based on your requirements.
What are the advantages of ServiceNow cloud solutions?
The advantages of ServiceNow cloud solutions include scalability, reduced IT infrastructure costs, enhanced security, and seamless software updates, enabling organizations to focus on core business objectives.
How does ServiceNow enable collaboration among teams?
ServiceNow enables collaboration among teams by providing a centralized platform that facilitates real-time communication, task management, and data sharing, allowing teams to work together seamlessly and efficiently towards shared goals.
What is the future of ServiceNow consulting?
The future of ServiceNow consulting lies in the growing demand for comprehensive and tailored solutions that leverage the platform's capabilities to drive digital transformation and streamline business processes.
How to leverage ServiceNow for process optimization?
Leveraging ServiceNow for process optimization involves streamlining workflows, automating repetitive tasks, and leveraging the platform's robust capabilities to enhance operational efficiency and drive continuous improvement within an organization.