UiPath Documentation
activities
latest
false
Importante :
A tradução automática foi aplicada parcialmente neste conteúdo. A localização de um conteúdo recém-publicado pode levar de 1 a 2 semanas para ficar disponível.

Atividades de integrações clássicas

Início rápido — objetos e anexos

Visão geral

O objetivo deste guia é ajudar você a criar uma amostra de trabalho que usa as seguintes atividades do ServiceNow:

Este exemplo de trabalho permite que você verifique rapidamente a conexão com sua instância do ServiceNow e se familiarize com os tipos de dados de entrada/saída da atividade.

Depois de concluir as etapas deste guia, você terá uma sequência de automação que faz o seguinte:

  1. Estabelece uma conexão com sua instância do ServiceNow (Escopo do ServiceNow).

  2. Cria um novo incidente do ServiceNow (Inserir Registro do ServiceNow).

  3. Carrega um arquivo para o novo incidente (Adicionar anexo).

  4. Baixa o arquivo carregado para uma pasta local (Baixar anexo).

  5. Exclui o arquivo carregado (Delete Attachment).

  6. Verifica se o arquivo foi excluído ao tentar recuperar o registro do anexo e gerar a mensagem de erro esperada (Get ServiceNow Record, If).

  7. Exclui o incidente criado (Delete ServiceNow Record).

Pré-requisitos

Antes de você começar:

  1. Conclua as etapas de Configuração do ServiceNow.
  2. Um arquivo local para anexar a um registro do ServiceNow.

Etapas

Crie seu projeto

  1. Adicione uma atividade.

  2. Enter the AssetName for the credential asset you created (during the Setup) for your ServiceNow instance username and password (e.g., "ServiceNowSignin").

  3. Create and enter a SecureString variable for your Password value (e.g., password).

  4. Create and enter a String variable for your Username value (.e.g, username).

  5. Add a second Get Credential activity.

  6. Enter the AssetName for the credential asset you created (during the Setup) for your ServiceNow instance Client Id and Client Secret (e.g., "ServiceNowClients").

  7. Create and enter a SecureString variable for your Password value (e.g., clientSecret).

  8. Create and enter a String variable for your Username value (.e.g, clientId).

  9. Adicione a atividade ServiceNow Scope após as duas atividades Get Credential .

  10. In the Client Secret property, enter the SecureString variable you created for your Client Secret in the steps above (e.g., clientSecret).

  11. In the Client Id property, enter the String variable you created for your Client Id (e.g., clientId).

  12. In the Password property, enter the SecureString variable you created for your password in the steps above (e.g., password).

  13. In the Username property, enter the String variable you created for your username (e.g., clientId).

  14. Create and enter a String variable for your EndpointURL (e.g., endpointURL)

  15. Adicione a atividade Insert ServiceNow Record dentro da atividade ServiceNow Scope .

  16. Clique no botão Configurar dentro da atividade Insert ServiceNow Record (isso abre o Assistente de Objetos.

  17. In Select Object drop-down list, select Incident.

  18. Create and enter a String variable for the sys_id Value (e.g., sysID)

  19. Using the Add Single Field textbox, enter short_description.

    • Enter a short_description Value (e.g., "UiPath-Attachment").
  20. Click Done.

  21. Create and enter a ResponseStatus variable for the ServiceNowStatus value (e.g., insertRecordResponse).

  22. Adicione uma atividade após a atividade Insert ServiceNow Record .

  23. 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).

  24. Adicione a atividade Add Attachment após a atividade Write Line .

  25. Click the Configure button inside the Add Attachment activity.

  26. In the Select Object drop-down list, select Incident.

  27. 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.

  28. In the ObjectSysId property, enter the sys_id variable you created for the Insert Record activity (e.g., sysID)

  29. Create and enter a String variable for the AttachmentId property (e.g., attachmentId).

  30. Create and enter a ResponseStatus variable for the ServiceNowStatus value (e.g., addAttachmentResponse).

  31. Adicione uma atividade após a atividade Insert ServiceNow Record .

  32. Enter the following Text: "Attachment added: "+addAttachmentResponse.Success.ToString+ " | sys_id: "+attachmentId (where attachmentId is the variable created for the AttachmentId property above).

  33. Adicione a atividade Download Attachment após a atividade Write Line .

  34. Enter the FilePath where you want to download the file (e.g., "C:\UiPath_Projects\Downloads").

  35. In the SysId property, enter the AttachmentId variable you created for the Add Attachment activity (e.g., attachmentId).

  36. Adicione a atividade Delete Attachment após a atividade Download Attachment .

  37. In the ObjectSysId property, enter the AttachmentId variable you created for the Add Attachment activity (e.g., attachmentId).

Teste seu projeto

  1. Adicione a atividade Get ServiceNow Record após a atividade Delete Attachment .

  2. Click the Configure button inside the Insert ServiceNow Record activity.

  3. In the Select Object drop-down list, select Attachment.

  4. In the sys_id Value field, enter the AttachmentId variable you created for the Add Attachment activity (e.g., attachmentId)

  5. Click Done.

  6. Create and enter a ResponseStatus variable for the ServiceNowStatus value (e.g., getRecordResponse).

  7. Adicione uma atividade após a atividade Get ServiceNow Record .

  8. 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).

  9. In the Then statement box, add a Write Line activity.

    1. In the Text property, enter "Test passed: "+getRecordResponse.Message.
    2. Adicione a atividade Delete ServiceNow Record após a atividade Write Line .
    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 a ResponseStatus variable for the ServiceNowStatus value (e.g., deleteRecordResponse).
  10. Add a Write Line activity after the Delete ServiceNow Record activity.

    1. Na propriedade Text , insira "Record excluído: "+deleteRecordResponse.Success.ToString.
  11. In the Else statement box, add a Write Line activity.

    1. In the Text property, enter "Test failed: "+getRecordResponse.Message.
  12. Click Run and verify the Output window includes the expected write line values.

Está feito!

Para saber mais sobre as atividades do ServiceNow (incluindo exemplos de entradas/saídas de propriedades), consulte a página Atividades para uma lista completa de atividades e links para as páginas de detalhes das atividades.

  • Visão geral
  • Pré-requisitos
  • Etapas
  • Crie seu projeto
  • Teste seu projeto

Esta página foi útil?

Conectar

Precisa de ajuda? Suporte

Quer aprender? Academia UiPath

Tem perguntas? Fórum do UiPath

Fique por dentro das novidades