- Getting started
- UiPath Add-in for Mulesoft
- UiPath Add-in for Microsoft Power Automate
- UiPath Add-in for Salesforce
- UiPath Add-in for ServiceNow
- UiPath Add-in for Workato
- UiPath Add-in for Workday

Add-ins user guide
Objects and attachments
The purpose of this guide is to help you create a working sample that uses the following ServiceNow activities:
- Insert ServiceNow Record
- Add Attachment
- Download Attachment
- Delete Attachment
- Get ServiceNow Record
- Delete ServiceNow Record
This working sample enables you to quickly verify the connection to your ServiceNow instance and get familiar with the activity's input/output datatypes.
Overview
After completing the steps in this guide, you'll have an automation sequence that does the following:
-
Establishes a connection to your ServiceNow instance (ServiceNow Scope).
-
Creates a new ServiceNow incident (Insert ServiceNow Record).
-
Uploads a file to the new incident (Add Attachment).
-
Downloads the uploaded file to a local folder (Download Attachment).
-
Deletes the uploaded file (Delete Attachment).
-
Verifies the file was deleted by trying to retrieve the attachment record and outputting the expected error message (Get ServiceNow Record, If).
-
Deletes the created incident (Delete ServiceNow Record).

Prerequisites
Before you begin:
- Complete the ServiceNow Setup steps.
- A local file to attach to a ServiceNow record.
Steps
Build your project
-
Add a Get Credential activity.
-
Enter the AssetName for the credential asset you created (during the Setup) for your ServiceNow instance username and password (e.g.,
ServiceNowSignin). -
Create and enter a
SecureStringvariable for your Password value (e.g.,password). -
Create and enter a
Stringvariable for your Username value (e.g.,username). -
Add a second Get Credential activity.
-
Enter the AssetName for the credential asset you created (during the Setup) for your ServiceNow instance Client Id and Client Secret (e.g.,
ServiceNowClients). -
Create and enter a
SecureStringvariable for your Password value (e.g.,clientSecret). -
Create and enter a
Stringvariable for your Username value (e.g.,clientId). -
Add the ServiceNow Scope activity after the two Get Credential activities.
-
In the Client Secret property, enter the
SecureStringvariable you created for your Client Secret in the steps above (e.g.,clientSecret). -
In the Client Id property, enter the
Stringvariable you created for your Client Id (e.g.,clientId). -
In the Password property, enter the
SecureStringvariable you created for your password in the steps above (e.g., password). -
In the Username property, enter the
Stringvariable you created for your username (e.g.,clientId). -
Create and enter a
Stringvariable for your EndpointURL (e.g.,endpointURL). -
Add the Insert ServiceNow Record activity inside the ServiceNow Scope activity.
-
Click the Configure button inside the Insert ServiceNow Record activity (this opens the Object Wizard.
-
In Select Object drop-down list, select Incident.
-
Create and enter a
Stringvariable for the sys_id Value (e.g.,sysID) -
Using the Add Single Field textbox, enter
short_description.- Enter a short_description Value (e.g.,
UiPath-Attachment).
- Enter a short_description Value (e.g.,
-
Click Done.
-
Create and enter a
ResponseStatusvariable for the ServiceNowStatus value (e.g.,insertRecordResponse). -
Add a Write Line activity after the Insert ServiceNow Record activity.
-
Enter the following Text: "Record created: "+insertRecordResponse.Success.ToString+" | sys_id: "+sysID (where
sysIDis the variable created for the sys_id Value field above).
-
Add the Add Attachment activity after the Write Line activity.
-
Click the Configure button inside the Add Attachment activity.
-
In the Select Object drop-down list, select Incident.
-
In the FileName property, enter the full path to your local file (e.g.,
"C:\UiPath_Projects\DemoFile.docx") or click the Choose File button in the activity. -
In the ObjectSysId property, enter the sys_id variable you created for the Insert Record activity (e.g.,
sysID) -
Create and enter a
Stringvariable for the AttachmentId property (e.g.,attachmentId). -
Create and enter a
ResponseStatusvariable for the ServiceNowStatus value (e.g.,addAttachmentResponse). -
Add a Write Line activity after the Insert ServiceNow Record activity.
-
Enter the following Text: "Attachment added: "+addAttachmentResponse.Success.ToString+ " | sys_id: "+
attachmentId(whereattachmentIdis the variable created for the AttachmentId property above). -
Add the Download Attachment activity after the Write Line activity.
-
Enter the FilePath where you want to download the file (e.g.,
"C:\UiPath_Projects\Downloads"). -
In the SysId property, enter the AttachmentId variable you created for the Add Attachment activity (e.g.,
attachmentId). -
Add the Delete Attachment activity after the Download Attachment activity.
-
In the ObjectSysId property, enter the AttachmentId variable you created for the Add Attachment activity (e.g.,
attachmentId).
Test your project
-
Add the Get ServiceNow Record activity after the Delete Attachment activity.
-
Click the Configure button inside the Insert ServiceNow Record activity.
-
In the Select Object drop-down list, select Attachment.
-
In the sys_id Value field, enter the AttachmentId variable you created for the Add Attachment activity (e.g.,
attachmentId) -
Click Done.
-
Create and enter a
ResponseStatusvariable for the ServiceNowStatus value (e.g.,getRecordResponse). -
Add an If activity after the Get ServiceNow Record activity.
-
In the Condition property, enter
getRecordResponse.Success=False And getRecordResponse.Message.Contains("No Record")to determine if the attachment record was successfully deleted by checking the error message (wheregetRecordResponseis the variable you created for the ServiceNowStatus property above). -
In the Then statement box, add a Write Line activity.
- In the Text property, enter "Test passed: "+
getRecordResponse.Message.
- In the Text property, enter "Test passed: "+
-
Add the Delete ServiceNow Record after the Write Line activity.
- Click the Configure button inside the Add Attachment activity.
- In the Select Object drop-down list, select Incident.
- In the Id property, enter the sys_id variable you created for the Insert Record activity (e.g.,
sysID). - Create and enter a
ResponseStatusvariable for the ServiceNowStatus value (e.g.,deleteRecordResponse).
-
Add a Write Line activity after the Delete ServiceNow Record activity.
- In the Text property, enter "Record deleted: "+
deleteRecordResponse.Success.ToString.
- In the Text property, enter "Record deleted: "+
-
In the Else statement box, add a Write Line activity.
- In the Text property, enter "Test failed: "+
getRecordResponse.Message.
- In the Text property, enter "Test failed: "+
-
Click Run and verify the Output window includes the expected write line values.

You're done!
To learn more about the ServiceNow activities (including example property inputs/outputs), see the Activities page for a complete activity list and links to the activity detail pages.