608 views

Business rule Execute Rest to SMAX itself

Jump to solution

Hi,

 

Is it possible to use the workflow business rule Execute Rest to make a request to SMAX's Rest API itself?

I need to add a comment to the parent entity of a task when the task is completed. Since there is no rule to do this OOB, I thought of making a request to the Comments API.

I've tried doing this to an external API to test it and it worked. I've used the JSON Placeholder API (https://jsonplaceholder.typicode.com/). I've setup the REST Agent and the REST Executor Endpoint to the address https://jsonplaceholder.typicode.com/. Then I've set up the rule to use this agent and endpoint and to make a GET request using the Uri Suffix "todos/1" and then to put the request result into a custom field of type LARGE_TEXT (Rest Request Result). This worked successfully according to the images below:

test_executerest_rule.PNG

test_executerest_response.PNGtest_executerest_endpoint.PNG

Then I tried to do a request to the SMAX Rest API (Comments API). I've setup a new endpoint pointing to the rest URL:

executerest_endpoint_config.PNG

Then I set up the Execute Rest Rule to point to this endpoint and to make a GET request with the Uri Suffix "${concat('collaboration/comments/Request/',entity.ParentEntityId)}", which complements the endpoin URL to form the correct url to the API: "https://<host_address>/rest/158349064/collaboration/comments/Request/<parent_id>". I then enter the same Headers I use with Postman: "Content-Type: application/json" and "User-Agent: Apache-HttpClient/4.4.1" and set the result to be copied to the custom field, like before.

executerest_rule.PNG

When I force the rule to run, then the endpoint fails and the Rest Request Result field is not filled.

executerest_endpoint_result.PNG

Is what I'm trying to do possible? If yes, what I am doing wrong?

 

Cheers

Tomas Azevedo

0 Likes
1 Solution

Accepted Solutions
Micro Focus Expert
Micro Focus Expert

Hello,

Calling SMAX back using the REST API is not supported.

If the requirement is to update the parent based on information from the task, this is possible with business rules. While adding a comment directly will not work, updating a field on the request is an option. You can append a new "entry" in a rich text field every time a task completes.

If you would like to have the information in comments, you can add a business rule on the field, and then if the field changes, copy the content in a new comment. In this case, you don't need to append to it, just do a straight update from the Task workflow.

For other examples of how to pass information from the task to the parent record, please check the Practitioner Forum session from Oct 24th, 2018 ("Office Hours: Solution Snippet")

In my example below, I updated the Notes field, and appending a new line, every time a task completes.

Here is the business rule:

${concat(entity.parentEntity.Notes,'<p>Task competed Id=', entity.Id,' Title=',entity.DisplayLabelKey,'</p>')}

TaskRule.PNG

 

.. an offering task plan:

TaskPlan.PNG

... and the end result on a Request:

Request.PNG

 

Best regards,
Brindusa

View solution in original post

2 Replies
Micro Focus Expert
Micro Focus Expert

Hello,

Calling SMAX back using the REST API is not supported.

If the requirement is to update the parent based on information from the task, this is possible with business rules. While adding a comment directly will not work, updating a field on the request is an option. You can append a new "entry" in a rich text field every time a task completes.

If you would like to have the information in comments, you can add a business rule on the field, and then if the field changes, copy the content in a new comment. In this case, you don't need to append to it, just do a straight update from the Task workflow.

For other examples of how to pass information from the task to the parent record, please check the Practitioner Forum session from Oct 24th, 2018 ("Office Hours: Solution Snippet")

In my example below, I updated the Notes field, and appending a new line, every time a task completes.

Here is the business rule:

${concat(entity.parentEntity.Notes,'<p>Task competed Id=', entity.Id,' Title=',entity.DisplayLabelKey,'</p>')}

TaskRule.PNG

 

.. an offering task plan:

TaskPlan.PNG

... and the end result on a Request:

Request.PNG

 

Best regards,
Brindusa

View solution in original post

Thank you, @Brindusa Kevorkian .

This worked like a charm.

BR

Tomas Azevedo

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.