Use the Assign file action to produce a file stream for an attachment in the ServiceNow instance. The Assign file action produces a file stream from the ServiceNow instance and assigns the stream to a file variable.

Create a file stream for an attachment in the ServiceNow instance using the attachment system id and assign it to a file variable. You can then use this file variable as a data source to upload the attachment to your Microsoft 365 OneDrive folder.

Prerequisites

Ensure that you meet the following prerequisites.
  • Set up an active connection to the ServiceNow instance using the Authentication action. For more information about Authentication action, see ServiceNow authentication action.
  • Set up an OAuth connection to Microsoft account.
  • Save the Microsoft account username in Credential Vault.
  • Create a file variable named servicenowfilestream to hold the file stream.

Procedure

  1. Create a task bot.
  2. Go to Actions > ServiceNow > Attachments and double-click Assign file to add the action to the editor.
  3. Enter the attachment id of the file from ServiceNow instance in Attachment sys_id.
    You can also map the attachment id to a string variable and select the variable using Insert a value option.
  4. By default, the system sets the session name as Default in Session name.
  5. Select the servicenowfilestream file variable from the Assign file to a variable drop-down.
  6. Go to Actions > Microsoft 365 OneDrive and double-click Connect to add the action to the editor.
    For more information about Connect action, see Using Connect action in Microsoft 365 OneDrive package.
  7. By default, the system sets the Microsoft 365 OneDrive user session name as Microsoft365OneDriveUserSession.
  8. Select Control Room managed in OAuth2 Authentication Mode and configure the following:
    1. Click Pick option and follow the prompts to choose the preconfigure OAuth connection to Microsoft account.
    2. Select Credential > Choose and follow the prompts in Pick a credential modal to choose the Microsoft account user name that is available in the Credential Vault.
  9. Go to Actions > Microsoft 365 OneDrive and double-click Upload file to add the action to the editor.
    For more information about Upload file action, see Upload file action .
  10. By default, the system chooses Microsoft365OneDriveUserSession as the session name in Microsoft 365 OneDrive user session.
  11. Select Variable in File variable / File name on local directory.
  12. Click Insert a value and select the servicenowfilestream file variable.
  13. Enter the folder path of the Microsoft 365 OneDrive location in Upload folder on OneDrive.
    For example, enter https://companyname-my.sharepoint.com/:b:/g/personal/abc/, where abc is the folder in which the attachment must be saved.

Next steps

When you run the automation, the system streams the file from the ServiceNow instance and assigns the file variable servicenowfilestream to the file stream. The Microsoft 365 OneDrive Upload action uses this servicenowfilestream file variable to upload the ServiceNow attachment to the specified Microsoft 365 OneDrive location.