Forums

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

Changing custom field value (radio button) according to other custom field value.

Mobileye Atlassian Licenses
June 27, 2018

Hi,

 

I have 2 custom fields:

1. scripted field that calculates some integer value.

2. Radio button with 5 options.

 

I want to add a behavior to the scripted field that will cause to a changing of the Radio button field. The condition should be this:

If (scripted field value <= 0 ){

Radio button option = A

}

else{

Keep the original value of the Radio button field.

}

 

 

Can anyone please assist me with this?

 

Thanks in Advance!

3 answers

1 accepted

Suggest an answer

Log in or Sign up to answer
1 vote
Answer accepted
Sammo Gabay
April 30, 2018

Using the DefaultRenderer class from the Java API worked for us. The renderer will convert macros to XML format, although anything that requires Javascript would of course not render outside of Confluence.

import com.atlassian.confluence.content.render.xhtml.DefaultRenderer;
import
com.atlassian.sal.api.component.ComponentLocator;

// page is an instance of com.atlassian.confluence.core.ContentEntityObject
DefaultRenderer renderer = ComponentLocator.getComponent(DefaultRenderer);
String content = renderer.render(page)
cloud-operations
December 20, 2018

Maybe I'm doing something wrong, but this code doesn't render macros, it outputs them as the placeholders as you would see them in the editor.

Sammo Gabay
January 8, 2019

Many macros offload their loading and rendering to JavaScript and the UI so the page itself will load faster. Any content that gets rendered in the UI via AJAX/JavaScript will not appear in the XML output, so it’s not a perfect solution.

1 vote
Yusuf TAMBAG
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 1, 2020

If anyone needs rendering html I found this method using XhtmlContent component

 

xhtmlContent.convertStorageToView(        page,        new DefaultConversionContext(page.toPageContext())    );
0 votes
Dar Kronenblum
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.
April 30, 2018

try to use page.getBodyAsString()

Sammo Gabay
April 30, 2018

Hi Dar,

I found that getBodyAsString() didn't fit my needs because it returns the raw, unprocessed page XML with all the macros unrendered.

Brian Rankin
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 16, 2019

Hi Sammo,

Can you post the Scriptrunner script that you used both to a) render and b) email the blog page? Would be great to see how it's done!

Thank you!

Sammo Gabay
October 22, 2019

Hi Brian, the above snippet will render the content of a page to XML (see caveat about it being imperfect). I am not exactly certain how to send an e-mail using the Confluence Java API. We are using an program called Sendy to send these newsletters out. It has a simple REST API to use.

TAGS
AUG Leaders

Atlassian Community Events