- Overview
- Adobe Sign
- Alteryx
- Amazon Comprehend
- Amazon Connect
- Amazon Rekognition
- Amazon Textract
- Box
- Release notes
- About the Box activity package
- Fix XAML After Package Update
- Project compatibility
- Setup
- Technical references
- Box Scope
- Commit Session
- Create File Version Session
- Create Upload Session
- Upload Part
- Delete Old Version
- Get Versions
- Promote Version
- Upload File Version
- Copy File
- Delete File
- Download File
- Get File Comments
- Get File Info
- Get File Info Details
- Get File Lock Info
- Lock File
- Move File
- Unlock File
- Upload File
- Copy Folder
- Create Folder
- Delete Folder
- Get Folder Info
- Get Folder Items
- Rename Folder
- Search For Content
- Execute Method
- Cognitive
- DocuSign
- Release notes
- About the DocuSign activity package
- Project compatibility
- Setup
- DocuSign Scope
- Invoke DocuSign Operation
- Create Envelope
- Create Envelope And Send
- Create Envelope From Template
- Create Envelope Recipients
- Get Document
- Get Documents
- Get Envelope
- Get Form Data
- Send Envelope
- Update Envelope
- List Attachments
- List Custom Fields
- List Documents
- List Envelope Status Changes
- List Recipients
- Create Bulk Send List
- Create Bulk Send Request
- Get Bulk Send List
- Get Bulk Send Lists
- Create Template Custom Fields
- Create Template Recipients
- Get Template
- List Templates
- Google Vision
- Jira
- Release notes
- About the Jira activity package
- Project compatibility
- Setup
- Jira Scope
- Execute Method
- Add Attachment
- Delete Attachment
- Download Attachment
- Get Attachments
- Add Comment
- Delete Comment
- Get Comments
- Create Component
- Delete Component
- Get Components
- Search Dashboards
- Create Filter
- Get Filters
- Create Issue Link
- Delete Issue Link
- Get Issue Link Types
- Get Issue Links
- Add Watcher
- Assign Issue
- Clone Issue
- Create Issue
- Delete Issue
- Get Issue
- Get Watchers
- Remove Watcher
- Search Issues Using JQL
- Transition Issue
- Update Issue
- Create Project
- Delete Project
- Get Project Types
- Get Projects
- Update Project
- Get Transitions
- Create User
- Delete User
- Find Users
- Marketo
- Microsoft Dynamics
- Microsoft Dynamics Finance and Operations
- Microsoft Translator
- Microsoft Vision
- Oracle Integration Cloud
- Oracle NetSuite
- Salesforce
- Release notes
- About the Salesforce activity package
- Project compatibility
- Setup
- Quickstart
- Salesforce Application Scope
- Create Bulk API Job
- Get Bulk API Job
- Get Bulk API Job Results
- Start or Abort Bulk API Job
- Assign File
- Download File
- Upload File
- Composite Request
- Delete Record
- Get List View Records
- Get Record
- Insert Record
- Update Record
- Upsert Record
- Execute Report
- Execute SOQL
- Format Column Names
- Format Labels And Values
- Lightning REST API Request
- Search
- SAP BAPI
- ServiceNow
- Slack
- Smartsheet
- Release notes
- About the Smartsheet activity package
- Project compatibility
- Setup
- Technical references
- Quickstart: Working With Rows
- Smartsheet Application Scope
- Attach File
- Attach URL
- Delete Attachment
- Get Attachment
- List Attachments
- Add Comment
- Delete Comment
- Get Comment
- List Discussions
- Copy Folder
- Create Folder
- Delete Folder
- Get Folder
- List Folders
- Add Group Members
- Get Group
- List Groups
- Remove Group Member
- Get Report
- List Reports
- Add Rows
- Copy Rows
- Create Discussion on Row
- Delete Rows
- Get Row
- List Rows
- Move Rows
- Update Rows
- Copy Sheet
- Create Sheet
- Create Sheet From Template
- Download Sheet
- Get Sheet
- List Sheets
- Update Sheet
- Add User
- Get User
- List Users
- Remove User
- Copy Workspace
- Create Workspace
- List Workspaces
- Import Sheet From CSV / XLSX
- Invoke Smartsheet Operation
- Search Activity
- Send Via Email
- Share Object
- SuccessFactors
- Tableau
- Twilio
- Workato
- Workday
Quickstart - 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.
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).
Before you begin:
- Complete the ServiceNow Setup steps.
- A local file to attach to a ServiceNow record.
Build your project
- Add a 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
SecureString
variable for your Password value (e.g., password). - Create and enter a
String
variable 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
SecureString
variable for your Password value (e.g., clientSecret). - Create and enter a
String
variable for your Username value (.e.g, clientId). - Add the ServiceNow Scope activity after the two Get Credential activites.
- In the Client Secret property, enter the
SecureString
variable you created for your Client Secret in the steps above (e.g., clientSecret). - In the Client Id property, enter the
String
variable you created for your Client Id (e.g., clientId). - In the Password property, enter the
SecureString
variable you created for your password in the steps above (e.g., password). - In the Username property, enter the
String
variable you created for your username (e.g., clientId). - Create and enter a
String
variable 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
String
variable 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").
- Click Done.
- Create and enter a
ResponseStatus
variable for the ServiceNowStatus value (e.g., insertRecordResponse). - Add a activity after the Insert ServiceNow Record activity.
-
Enter the following Text: "Record created: "+insertRecordResponse.Success.ToString+" | sys_id: "+sysID (where sysID is 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
String
variable for the AttachmentId property (e.g., attachmentId). - Create and enter a
ResponseStatus
variable for the ServiceNowStatus value (e.g., addAttachmentResponse). - Add a activity after the Insert ServiceNow Record activity.
- Enter the following Text: "Attachment added: "+addAttachmentResponse.Success.ToString+ " | sys_id: "+attachmentId (where attachmentId is 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
ResponseStatus
variable for the ServiceNowStatus value (e.g., getRecordResponse). - Add an 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 (where getRecordResponse is the variable your created for the ServiceNowStatus property above).
-
In the Then statement box, add a Write Line activity.
1. In the Text property, enter "Test passed: "+getRecordResponse.Message.
2. Add the Delete ServiceNow Record after the Write Line activity.
3. Click the Configure button inside the Add Attachment activity.
4. In the Select Object drop-down list, select Incident.
5. In the Id property, enter the sys_id variable you created for the Insert Record activity (e.g., sysID).
6. Create and enter aResponseStatus
variable for the ServiceNowStatus value (e.g., deleteRecordResponse). -
Add a Write Line activity after the Delete ServiceNow Record activity.
1. In the Text property, enter "Record deleted: "+deleteRecordResponse.Success.ToString.
-
In the Else statement box, add a Write Line activity.
- In the Text property, enter "Test failed: "+getRecordResponse.Message.
-
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.