Gen 2 Custom Value
  • 22 Jun 2022
  • Dark
    Light
  • PDF

Gen 2 Custom Value

  • Dark
    Light
  • PDF

Article Summary

In this section, we'll introduce the concept of replacing values by utilizing the replace task to customize the API URL so that we can receive a slightly different output.

Get Prepared to Pass Variables

With the test API we've been using, you can have some additional fun by injecting your own name within the Chuck Norris facts. Fortunately, the test API we've been using will allow us to demonstrate this; but first, we'll need to set-up some more tasks to handle the additional information.

There are a few ways to do this, but for purposes of this guide, we'll stick with a simple method that uses a few replace tasks to illustrate how variables are passed within an automation. As you become more comfortable with the capabilities of IAP and other various tasks, you may discover another more efficient method to accomplish the same goal.

Add More Tasks to an Automation

By clicking on a transition line, a user may choose the context menu options "Insert Node" or "Delete Transition".

Figure 1: Insert Node

01_GEN2-AddNode (1)

  1. Add three (3) additional nodes above the "FetchFact" node on the canvas.
  2. Change the new nodes so that they are replace nodes.
  3. In the Details for each of the new nodes:
    • Name the first Node OriginalURL.
    • Name the second Node FirstName-Update.
    • Name the third Node LastName-Update.

Figure 2: Additional Nodes Added

02_GEN2-CustomValuesLayout

Build the API URI

The Chuck Norris API will accept the following format and return a customized name within the fact.

http://api.icndb.com/jokes/random?firstName={firstname}&lastName={lastName}
  1. Click to open the first of the replace tasks you previously added (the one you named "OriginalURL".)
  2. For the str variable, provide the following URL as the Value (without quotes): http://api.icndb.com/jokes/random?firstName=customfirstname&lastName=customlastname.
  3. Click the Save icon to save your work.

We're using this "OriginalURL" (replace) task as a placeholder for raw URL storage. You could simply use this "Original URL" as the RestCall URI, but it would yield very boring results.

Configure the Replace Nodes

The second and third replace nodes ("FirstName-Update" and "LastName-Update", respectively) will swap out the generic customfirstname and customlastname phrases in the value of our OriginalURL node with something more interesting.

  1. Click to open the replace node named "FirstName-Update".

  2. For the str variable:

    • Change the Reference Task to OriginalURL.
    • The Reference Variable should default to replacedString.
  3. For the substr variable:

    • Keep the Reference task setting as Static.
    • Change the Reference variable to (without quotes) customfirstname.

    You will probably recognize this value (phrase) from the URL that was provided for the FactURL task.

  4. For the newSubstr variable:

    • Leave the Reference task set to Static.
    • Change the Value to whatever firstname amuses you.
  5. Save the automation.

  6. Click to open the replace node named "LastName-Update".

  7. For the str variable:

    • Change the Reference task to FirstName-Update.
    • The Reference Variable should default to replacedString.
  8. For the substr variable:

    • Keep the Reference task setting as Static.
    • Change the Reference variable to (without quotes) customlastname.

    Again, you will probably recognize this value (phrase) from the URL that was provided for the FactURL task.

  9. For the newSubstr variable:

    • Keep the Reference task setting as Static.
    • Change the Value to whatever lastname amuses you.
  10. Save the task.

As a checkpoint, let's review what you've done so far:

  • Created a URL template ("OriginalURL").
  • Created two replace tasks that sequentially take the OriginalURL template and swap out "firstName" and "lastName" information into the appropriate spots within the URL.

Now all you need to do is provide the updated URL to the RestCall itself.

Finish Connecting & Configuring Tasks

Complete these last few steps to connect and configure all your tasks:

  1. Click to open the FetchFact task.
  2. Change the uri variable:
    • Change the Reference task to LastName-Update.
    • Keep the default replacedString value for the Reference variable.
  3. Save the task.

You should now have a workflow with seven (7) connected tasks in the following order:

  1. START
  2. OriginalURL
  3. FirstName-Update
  4. LastName-Update
  5. FetchFact
  6. IsolateFact
  7. END

Run the Automation

After running the workflow, go to the IsolateFact (Query) Task Details within Jobs (Operations Manager). You should find that instead of "Chuck Norris", the joke now uses the custom name. In the example, the custom name is "River Phenix".

Figure 3: Custom Name Value

03-GEN2-CustomNameValue-21.2

Summary Wrap-Up

A job well done! You've learned how to create a URL template, customize values in your sample API, and build a more complex automation using the replace task.

In the next section, you'll create a user input form that allows you to reuse the custom name automation you just built.


Was this article helpful?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.