Space banner

 

This documentation supports the 20.02 version of BMC Digital Workplace Advanced.

To view the latest version, select the version from the Product Version menu.

Using the Json Parser string manipulation method to retrieve information

This topic describes an example workflow that uses the Json Parser String Utils workflow action to retrieve Work Order Details and Details2, and send them through email.

Following is a high-level description of each element in this example workflow:

ElementDescription
Get Remedy Work Order By ID

Retrieves the work order's request ID, which is needed for the next action (Get Entry). The Get Remedy Work Order By ID element also retrieves other information, but it does not retrieve the Details and Details2 information of the work order. (The next element below helps to resolve this issue.)


Get Entry (Get Work Order Details in the example above)

Retrieves the entry information in the key/value view: " <Field name> " : " <Field value> ". The Get Entry action output has the work order's Details and Details2 information. In this workflow example, we want to find all values with keys that start with WO Type Field.

The Json Parser action (a few elements below) has restrictions that do not allow the action to filter by the partial name of the key, but the action can search by partial value. So, the Get Entry action output is passed to the Build Input Set action.

Build Input Set

Converts the entry information as follows:

{ 
   "key": " < Field name > ", 
   "value": " < Field value > " 
}

Json Parser

With the Build Input Set element's output, finds keys that start with WO Type Field.

The Path For Search parameter in the Json Parser element should look like this:

 "$.inputs[?(@.key =~ /WO Type Field .*/i)]" 

where key should contain the text you want to find, and i means that search will be case insensitive.

Compute Value

Helps to collect the Json Parser output into a nicely formatted string (which includes <br> tags for new lines). You can then use this string as the content for the Send Email action, which uses STRIPHTML to convert the <br> tags into new lines.

In the OUTPUT MAP section for this Compute Value element, the workflow uses the current value of the Content variable (which begins as empty text), and appends the following string to it:

WO detail key : WO detail value ; <new line>

To collect the Content data, the results of the Json Parser element are processed one by one. If the Json Parser element finds five details, this Compute Value element is triggered five times (one for every detail).

A result is assigned to SingleWODetailsObject, and the key and value is retrieved from it, for example:

"${processContext.SingleWoDetailsObject.key} + " : " + ${processContext.SingleWoDetailsObject.value} + ";  <br>"

The MULTI INSTANCE LOOP section uses the Json Parser output:

For information about the output map and multi instance loop, see the following topics:

Send Email

Sends the result, which might look something like this:

For an example of this workflow, see the attached workflow.json file.

Was this page helpful? Yes No Submitting... Thank you

Comments

  1. Alexander Stern

    This is not working: ${processContext.SingleWoDetailsObject.key} + " : " + ${processContext.SingleWoDetailsObject.value} + "; ",

    you will get an Error, even if SingleWoDetailsObject variable is there.

    Mar 05, 2021 08:00
    1. Ravee Panjwani

      Can you please confirm if that still does not work for you? We noticed a missing opening quote " in the documentation which might be the cause.

      Apr 14, 2021 06:42