Encode URL in manual task

Options

I have a manual task with a text body something like this:

If this will take more than a week, please consider sending an email to {{contractor-name}}

We'd like to make "sending an email" a mailto link and embed {{contractor-name}} in the &body= section. A problem arises when {{contractor-name}} has a space in it, since the mailto URI must be encoded (namely, spaces replaced with %20.

Is there a way to encode the field before it populates the URI?

Thanks!

Answers

  • Chris_573086
    Chris_573086 Posts: 14 admin
    Options

    @Tom_855096 You can encode the field using our field formulas action in a previous step. The flow would work like this:

    • You set the value of {{contractor-name}} earlier in the run.
    • Create a field formula action and set the javascript code to the following with values that work for your intended target email: result = encodeURI("mailto:chahn@catalytic.com?body=contractor-name"); NOTE: contractor-name in the previous value is a field reference, and should be auto-populated using the selector that appears when you type {{ in the javascript form element. Just the plain text of contractor-name will not fill in the field value.
    • Set the Return field name to mailto-link, which we will use in the manually assigned task.
    • You manual task instructions can then be formatted like the following: If this will take more than a week, please consider [sending an email]({{mailto-link}}) to {{contractor-name}}. NOTE: the usage of markdown's link insert notation, which is (link text)[link target].

    Please let us know if you run into any issues implementing this.