Extract URL from rich text URL using smart values

Ahmad Sidawi
Contributor
March 29, 2024

Hi,

I'm trying to extract a rich text formatted URL to input into a URL field using smart values. Is there a way to do this?

The input is something like this:

[https://community.atlassian.com/t5/forums/postpage/choose-node/true/interaction-style/qandahttps://community.atlassian.com/t5/forums/postpage/choose-node/true/interaction-style/qanda]

I'd like the output of:

https://community.atlassian.com/t5/forums/postpage/choose-node/true/interaction-style/qanda

I've tried splits, substring, encode, none of them have worked. Any ideas?

1 answer

1 vote
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 29, 2024

Hi @Ahmad Sidawi 

For a question like this, please post an image of your complete automation rule, images of any relevant actions / conditions / branches, an image of the audit log details showing the rule execution, and explain what is not working as expected.  Those will provide context for the community to offer ideas.  Thanks!

Until we see those...

Several of text functions, including match() with a regular expression, should work for this.  The specifics will depend upon what your example input looks like, how many URL you expect in the field, etc.

One expression, based one what you show and assuming only one URL, could be:

{{issue.yourField.substringBetween("[","]").split("|").get(1).trim()}}

Kind regards,
Bill

Ahmad Sidawi
Contributor
March 29, 2024

Hi Bill,

This automation gets data across instances which is formatted differently in the first instance.

The point of failure is trying to create the variable and update the 'Link to Test Report' field (URL field). Other fields are OK.

image.png

 

Tried your suggestion, its returning just the 'h' from all the characters:

image.png

 

Thanks,

Ahmad

Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 29, 2024

What I suggested was based on what you showed, assuming it was from the plain text.  It appears what you showed in the question does not reflect the plain text representation of the markup in the field.  

 

I suggest writing the field to the audit log by itself, run the rule, review the log, and that will clarify which functions are needed to parse the URL. 

Better still: find an example issue with your field and call the REST API get issue function with a browser tab and view directly what the field contains: https://support.atlassian.com/cloud-automation/docs/find-the-smart-value-for-a-field/

 

 

For example, here is the markup guide, and I suspect it is the link formats, and so get(1) should be used instead after the split: https://jira.atlassian.com/secure/WikiRendererHelpAction.jspa?section=all

Muhammad Rikaz Khan
Banned
March 29, 2024

I suggest writing the field to the audit log by itself, run the rule, review the log, and that will clarify which functions are needed to parse the URL. 

Ahmad Sidawi
Contributor
April 1, 2024

As shown in the rule above, values of the field were already being logged. Could be some hidden characters not being included in the log as the split by ("|") character is splitting every letter.

Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 1, 2024

That is possible: there is no documentation on what the rule engine does to present the content shown in the log.  (e.g., removing control characters)

Please use the how-to article I noted earlier for "Find the smart value for a field".  With that...

  • you may call a REST API function to present the issue data as JSON in a browser tab,
  • directly examine the contents of your field, and
  • use that information to decide which text functions are needed to parse out the URL.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events