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,301,303
Community Members
 
Community Events
165
Community Groups

Confiforms Drag and Drop: Index does not update after refreshing the page

I have used this example (ConfiForms form with drag and drop and REST API - Vertuna WIKI - TEST) to build a dragable form in Confiforms but unfortunately, the 'Ordernr' doesn't update after refreshing the page. 

When changing the order of the rows (by drag and drop) in my form and refreshing afterwards, it will fall back to the previous state. Is it possible that the rows remain in the new order?

1 answer

1 accepted

Hi @Ulrich Brinker 

Welcome to this community!

The question is tagged with cloud and confluence-cloud... I dont think there is a possibility to do what you want in the cloud.

The example you refer to is for server/dc

I have verified that example just now and it works fine for me - what exactly do you have? Let's see what is different

Alex

Hey @Alex Medved _ConfiForms_

thanks for your reply.

Since I never worked with Confluence/Confiforms before, I am the excact opposite of an expert. I can access my company's confluence page via browser, when I am connected into their network (VPN) and therefore, thought that it is cloud based, so maybe it is hosted on a server. I honestly don't know. Sorry.

However, I copied the sourcecode given under above mentioned link and get the non-persistant result described. After refreshing the page, the 'Ordernr' gets set back to the order number that I've assigned in the registration form beforehand. 

Is it possible that my form saves the new positions (new 'Ordernr') after Drag-and-Dropping them into the new position I need?

Have you changed the code to match your form and page id?

I have changed the formname of the ConfiForms Form Definition from "f1" to "f".

Thats all I changed.

If its relevant, here is the codeblock I am using right now:

<p>form</p>
<ac:structured-macro ac:macro-id="4f63e526-ab65-4a59-8cf7-baff43e3bf29" ac:name="confiform" ac:schema-version="1">
<ac:parameter ac:name="formName">f</ac:parameter>
<ac:rich-text-body>
<p class="auto-cursor-target">
<br/>
</p>
<ac:structured-macro ac:macro-id="6b21d235-3cb2-4f1c-b95c-1a7b09df9071" ac:name="confiform-entry-register" ac:schema-version="1">
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p>
<ac:structured-macro ac:macro-id="5f9ed3ad-449d-4a85-bdb7-d4b92262356c" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">title</ac:parameter>
<ac:parameter ac:name="fieldLabel">Title</ac:parameter>
<ac:parameter ac:name="type">text</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="9cd1501b-4577-42ca-9f55-a219b455d126" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">ordernr</ac:parameter>
<ac:parameter ac:name="fieldLabel">OrderNr</ac:parameter>
<ac:parameter ac:name="type">numberhidden</ac:parameter>
</ac:structured-macro>
</p>
<ac:structured-macro ac:macro-id="0f086456-1234-4143-bc47-80115ccce664" ac:name="confiform-field-definition-rules" ac:schema-version="1">
<ac:parameter ac:name="fieldName">ordernr=([entry.ordernr]+1)</ac:parameter>
<ac:parameter ac:name="action">Lookup and set value</ac:parameter>
<ac:parameter ac:name="values2">f:12222999</ac:parameter>
<ac:parameter ac:name="values3">ordernr DESC LIMIT 1</ac:parameter>
</ac:structured-macro>
</ac:rich-text-body>
</ac:structured-macro>
<p>records</p>
<ac:structured-macro ac:macro-id="4cc00cf5-1070-4a28-824f-b0d7ec842421" ac:name="confiform-table" ac:schema-version="1">
<ac:parameter ac:name="formName">f</ac:parameter>
<ac:parameter ac:name="sort">ordernr ASC</ac:parameter>
<ac:rich-text-body>
<p>
<ac:structured-macro ac:macro-id="c3b75cf6-477a-49b2-9f8e-d9267c81dceb" ac:name="confiform-field" ac:schema-version="1">
<ac:parameter ac:name="fieldName">ordernr</ac:parameter>
</ac:structured-macro>
</p>
<ac:structured-macro ac:macro-id="33d8e448-f88d-4f62-94b7-05ba87601181" ac:name="confiform-field" ac:schema-version="1">
<ac:parameter ac:name="fieldName">title</ac:parameter>
</ac:structured-macro>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p class="auto-cursor-target">
<br/>
</p>
<ac:structured-macro ac:macro-id="c0a424df-5b20-486c-8045-71b66e9e9814" ac:name="html" ac:schema-version="1">
<ac:plain-text-body><![CDATA[<script>

var fixHelperModified = function(e, tr) {
var $originals = tr.children();
var $helper = tr.clone();
$helper.children().each(function(index) {
AJS.$(this).width($originals.eq(index).width())
});
return $helper;
},
updateIndex = function(e, ui) {
AJS.$('td.cf_ordernr', ui.item.parent()).each(function (i) {
AJS.$(this).html(i + 1);
});

AJS.$(".cf_f_table tbody").find('tr').each(function(i, tr){
var entryId = AJS.$(this).attr('confi-data-id');
AJS.$.ajax({
url: 'https://wiki.vertuna.com/ajax/confiforms/rest/update.action?pageId=12222999&f=f1&q=id:' + entryId + '&fv=ordernr:' + (i+1),
type: "GET",
cache: false,
async: false,
success: function (data) {

}
});
});
};
AJS.$(".cf_f_table tbody").sortable({
helper: fixHelperModified,
stop: updateIndex
}).disableSelection();


</script>]]></ac:plain-text-body>
</ac:structured-macro>
<p class="auto-cursor-target">
<br/>
</p>

The code uses page id 12222999, which is the id of the page where the example is located.

You need to adjust it to match yours

And it also uses form name f1 (in the code)

f=f1

So, if you changed that you need to adjust that as well.

Thank you very much, it worked. 

I had to change this URL in the source code:

https://xxx.yyy.com/ajax/confiforms/rest/update.action?pageId=1122486467&f=f&q=id:

whereas xxx and yyy is the URL of my institution and 1122486467 the PageID for my specific page.

At the end of the URL I changed "f=f1" to "f=f" because I renamed the "Confiforms form definition Form Name" from "f1" to "f". 

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Confluence

An update on Confluence Cloud customer feedback – June 2022

Hi everyone, We’re always looking at how to improve Confluence and customer feedback plays an important role in making sure we're investing in the areas that will bring the most value to the most c...

427 views 2 13
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you