The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Error when put variables in function REPLACE()

Alexandra DM
Contributor
October 21, 2024

Hi, I'm trying to replicate  a simple test where I've created different variables to replace the content of div (html)

Variables

baseContent =

 <div id="content"> <p>This is the original content</p> <!--PLACEHOLDER--> </div>

valueReplace = 
<!--PLACEHOLDER-->

replaceContent =
<p>NEW CONTENT</p>

It only runs correctly when placed directly with values set in the double quotes combinedContent = {{baseContent.replace("PLACEHOLDER","W")}}

But when I want to pass the replaceContent  and/or valueReplace variable it doesn't appear in any of the following tests

{{baseContent.replace("<!--PLACEHOLDER-->", replaceContent)}} -error {{baseContent.replace("<!--PLACEHOLDER-->","${replaceContent}")}} -error {{baseContent.replace(\{\{valueReplace\}\},\{\{replaceContent\}\})}} -- error {{baseContent.replace("{{valueReplace}}","{{replaceContent}}")}} -error {{baseContent.replace({{valueReplace}},{{replaceContent}})}} -error {{baseContent.replace($(valueReplace),$(replaceContent) )}} -error

 What is the correct way to pass smart values to a replace ? It's Jira Automation Data Center

test_replace.png

2 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

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 Champions.
December 7, 2024

Hi @Alexandra DM 

I found an open defect for this symptom: https://jira.atlassian.com/browse/JIRAAUTOSERVER-975

It suggests a workaround to add trim() after the variable to force the type to text for the function parameter.  Perhaps try that as:

{{baseContent.replace("<!--PLACEHOLDER-->", replaceContent.trim())}}

 

As an aside, this defect implies the Create Variable action for Jira Data Center automation is not returning a "string" (i.e., text type), which is both different from Jira Cloud and does not match the Server / Data Center documentation:

https://confluence.atlassian.com/automation/jira-automation-actions-993924834.html#Jiraautomationactions-create-variableCreatevariable

 

Kind regards,
Bill

Robin
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 Champions.
September 10, 2025

thank you for this hint.

i searched for hours for that problem on my automation. creating a var first and then trim the content in there did the trick!

Like Bill Sheboy likes this
0 votes
Kseniia Trushnikova
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 Champions.
October 28, 2024

Hey @Alexandra DM,

This would work in Jira Cloud:

{{baseContent.replace(valueReplace,replaceContent)}}

But the same function doesn't work in Jira DC... Perhaps, nested smart values aren't a thing in Data Center yet.

DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events