How to: Use OO to automate the file attachment to SMAX entities.


Operations Orchestration can be used to automate different tasks in OpenText SMAX using the out-of-the-box SMAX integration. There is though a use case that is not available in the out-of-the-box integration but it's very easy to achieve using generic http client together with the SMAX integration. The following article talks about how you can automate SMAX file attachment use case in Operations Orchestration. Before you go through the steps, make sure you read the details about file attachment API in the SMAX integration:

This article is using Workflow Designer and the Cloudslang based content. Similar approach can be used in Studio.

Step 1. Import Cloudslang Base and OpenText SMAX Content Packs in the Workflow Designer dependencies panel.

Step 2. Create a new flow, name it smax_file_attachment.

Step 3. Use get_sso_token operation from the OpenText SMAX integration to authenticate in SMAX. This will generate an sso_token that can be used in the following http requests. 

Step 4. Use http_client_action from the base integration to add the attachment into the Service Management Automation X system. 

a. Use the following inputs: 

url -> https://<MasterNode>/rest/<tenantId>/ces/attachment.   (replace MasterNode and tenantId with your details)

authentication -> Basic

headers -> 'Cookie:LWSSO_COOKIE_KEY=' + sso_token + '; TENANTID=' + tenant_id. (use expression editor to interpret the string as an expression)

content_type -> text/plain (we upload a text file, this should be changed based on the file that you attach)

multipart_files -> "files[]= <file_path>"

multipart_files_content_type -> text/plain (we upload a text file, this should be changed based on the file that you attach)

method -> POST 

b. Configure the other generic http client inputs based on your needs. (keystore, truststore, hostname verifier, connection timeouts, etc.)

c. Create the following outputs: 

attachment_name -> (cs_json_query(return_result,'$.name'))[2:-2]

attachment_id -> (cs_json_query(return_result,'$.guid'))[2:-2]

attachment_size -> (cs_json_query(return_result,'$.contentLength'))[1:-1]

attachment_content_type -> (cs_json_query(return_result,'$.contentType'))[2:-2]

*make sure you use expression editor to provide the values, so they can be evaluated as python expressions

Step 5. Update the request that you want to attach the file to with the attachments properties. 

Depending on your entity (incident, request, etc). the attachments property may differ. Please consult the EMS properties for your specific entity.Also the update operation should be used accordingly to the entity that you update. This example will use a request entity so the property is called RequestAttachments and the operation that we'll use it's called update_request and is available in the out-of-the-box Opentext SMAX integration. 

a. Use update_request operation from the out-of-the-box OpenText SMAX integration to update your request properties and update the actual record with the attachment information.

b. Configure the operation inputs with the smax details and your entity id.

c. For the request_properties use the following value:

'"RequestAttachments":"{\\"complexTypeProperties\\":[ {\\"properties\\":{ \\"id\\":\\"' + attachment_id + '\\",\\"file_name\\":\\"'+ attachment_name +'\\",\\"file_extension\\":\\"txt\\",\\"size\\":\\"' + attachment_size + '\\",\\"mime_type\\":\\"' + attachment_content_type +'\\",\\"Creator\\":\\"' + username + '\\"}}]}"'

Step 6. Wire all the steps together and then to the Succes Result. Your flow is ready and can be used to attach files to a SMAX entity. 



Knowledge Docs
User Group
Comment List
  • Thank you for your post, it was quite useful and helped us solve our problem.
    But we have a difficulty: in our projects, customers use files that contain Cyrillic characters and it is not entirely clear to us in which settings we need to enter the UTF-8 value so that files containing Cyrillic characters are displayed correctly at the moment, if we upload files that contain Cyrillic, we receive question marks instead of the file name in response