Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,552,475
Community Members
 
Community Events
184
Community Groups

Can I get a ScriptRunner custom macro body in storage format?

Edited

I'm writing a ScriptRunner custom macro that will process its body, but I'd prefer to process storage format (which is valid XML) rather than view format (which isn't). Looking at ConversionContext, there are methods to convert storage to view but (not surprisingly I guess) not the other way round. 

As explained at https://docs.adaptavist.com/sr4c/latest/features/macros/custom-macros, the macro body is available in the body variable, but this appears to be view format and I don't see any way of requesting storage format. I checked whether there were any other hidden variables (such as bodyStorage) in the binding, but there don't appear to be.

Any ideas? Thanks.


UPDATE: I created a simple example that uses the "status" macro. Here is the storage format (I've inserted some line breaks to make it more readable):

<p class="auto-cursor-target"><br /></p>
<ac:structured-macro ac:name="inspect-body" ac:schema-version="1"
ac:macro-id="2c224875-7f90-41be-bf74-486fc930c58c">
<ac:rich-text-body>
<p>
<ac:structured-macro ac:name="status" ac:schema-version="1"
ac:macro-id="c6c51709-dfab-4cce-8a47-a8a878787f45">
<ac:parameter ac:name="title">Status</ac:parameter>
</ac:structured-macro>
</p>
</ac:rich-text-body>
</ac:structured-macro> <p class="auto-cursor-target"><br /></p>

inspect-body is my custom macro and it just returns the body HTML as literal text. The weird thing is that I'm seeing different view formats when previewing the macro in the macro editor:

<p>
<img class="editor-inline-macro" height="18" width="88"
src="/plugins/servlet/status-macro/placeholder?title=Status"
data-macro-name="status"
data-macro-id="c6c51709-dfab-4cce-8a47-a8a878787f45"
data-macro-parameters="title=Status"
data-macro-schema-version="1">
</p>

...and when saving the page (again I've added some newlines in both cases):

<p talk-marker="1" talk-page-id="116228112" talk-page-version="7">
<span class="status-macro aui-lozenge conf-macro output-inline"
data-hasbody="false" data-macro-name="status">STATUS</span>
</p>

I guess I need to be able to process both of the above (because I want the macro logic to execute both in the editor and when saving the page) but of course the <img> tag isn't terminated, so I can't parse it as XML. I guess I'll either preprocess it to make it valid XML or else do a naive parse (I don't care about the full details of the XML; I just want some bits, e.g., the status macro text).

Does this additional information help to point to the source of the problem, if indeed it is a problem?

Also, I don't suppose it's relevant, but the SR version is 6.36.0.

1 answer

0 votes
Fabian Lim
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Jan 09, 2022

Hi @William Lupton

I suggest you also contact adaptivist support directly for faster support.

Regards

Thanks @Fabian Lim and sorry for the delay in replying. Yes I will create a support ticket but in the meantime I have avoided the problem in the way that I suggested.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
7.11.0
TAGS
AUG Leaders

Atlassian Community Events