It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Confiform auto run "Set Value" action on Rules Macro

Ansar Rezaei Apr 23, 2019

Hi
I have a form and I need to change the value of specific field to default value after 10 days of last updated date. I create a form and hold  update date on a field using ifttt macro. When I update date field  manually Rule works fine, but I need to execute automatically on page/form load. Could you help me what's wrong with it? Is this senario possible with confiform or not?

==================================================================

<ac:structured-macro ac:macro-id="848cb8f1-87c8-4c75-a16a-f7ae12b18adc" ac:name="confiform" ac:schema-version="1">
<ac:parameter ac:name="formName">f1</ac:parameter>
<ac:rich-text-body>
<ac:structured-macro ac:macro-id="6e70de46-02f5-4244-ae5a-f3aeab659475" ac:name="confiform-entry-register" ac:schema-version="1">
<ac:parameter ac:name="formName">f1</ac:parameter>
<ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p>
<ac:structured-macro ac:macro-id="2c376518-07b1-4636-8a00-825f710b511d" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">status</ac:parameter>
<ac:parameter ac:name="fieldLabel">My text field</ac:parameter>
<ac:parameter ac:name="values">false[success=a|error=B|current=C|]</ac:parameter>
<ac:parameter ac:name="type">status</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="da4d3518-caf6-45da-addd-07ccf86a369f" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">updatedBy</ac:parameter>
<ac:parameter ac:name="fieldLabel">Updated by:</ac:parameter>
<ac:parameter ac:name="type">hidden</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="2453f5bc-edf3-49ec-a36d-09cc010f4e76" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">updatedDate</ac:parameter>
<ac:parameter ac:name="fieldLabel">Updated Date:</ac:parameter>
<ac:parameter ac:name="type">datetime</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="a8471e73-68e8-4773-82a6-cb2ca97301b7" ac:name="confiform-field-definition-rules" ac:schema-version="1">
<ac:parameter ac:name="condition">updatedDate:&lt;[now]-60</ac:parameter>
<ac:parameter ac:name="values">status=current</ac:parameter>
<ac:parameter ac:name="action">Set value</ac:parameter>
</ac:structured-macro>
</p>
<ac:structured-macro ac:macro-id="4b4e1bc5-9432-48e3-8968-7e37295cce44" ac:name="confiform-ifttt" ac:schema-version="1">
<ac:parameter ac:name="action">Create ConfiForms Entry</ac:parameter>
<ac:parameter ac:name="event">onCreated</ac:parameter>
<ac:parameter ac:name="title">entryId=[entry.id]&amp;updatedBy=[user]</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<ac:structured-macro ac:macro-id="535006ce-b3d9-4698-9356-0db560fb3499" ac:name="confiform-ifttt" ac:schema-version="1">
<ac:parameter ac:name="action">Create ConfiForms Entry</ac:parameter>
<ac:parameter ac:name="event">onCreated</ac:parameter>
<ac:parameter ac:name="title">entryId=[entry.id]&amp;updatedDate=[now]</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<ac:structured-macro ac:macro-id="207991aa-4e6c-4194-8310-bb48ad407b7b" ac:name="confiform-ifttt" ac:schema-version="1">
<ac:parameter ac:name="action">Create ConfiForms Entry</ac:parameter>
<ac:parameter ac:name="event">onModified</ac:parameter>
<ac:parameter ac:name="title">entryId=[entry.id]&amp;updatedBy=[user]</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<ac:structured-macro ac:macro-id="cac9e48a-eecd-4a34-a5dd-15ff7f82e235" ac:name="confiform-ifttt" ac:schema-version="1">
<ac:parameter ac:name="action">Create ConfiForms Entry</ac:parameter>
<ac:parameter ac:name="event">onModified</ac:parameter>
<ac:parameter ac:name="title">entryId=[entry.id]&amp;updatedDate=[now]</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
</ac:rich-text-body>
</ac:structured-macro>
<ac:structured-macro ac:macro-id="90673f38-7f9a-4be6-ad3c-5f46943c1948" ac:name="confiform-table" ac:schema-version="1">
<ac:parameter ac:name="formName">f1</ac:parameter>
<ac:rich-text-body>
<p>
<ac:structured-macro ac:macro-id="89b28b74-64ea-4082-b0a4-bc5f637ff28d" ac:name="confiform-field" ac:schema-version="1">
<ac:parameter ac:name="fieldName">status</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="d9a2031a-caeb-48e9-88d6-5829ab13dc7a" ac:name="confiform-field" ac:schema-version="1">
<ac:parameter ac:name="fieldName">createdBy</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="c90c2b7d-dcd6-4d13-939e-80d103d16c04" ac:name="confiform-field" ac:schema-version="1">
<ac:parameter ac:name="fieldName">updatedBy</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="4e43bb45-b9cc-46c3-9c0a-bf356d704a15" ac:name="confiform-field" ac:schema-version="1">
<ac:parameter ac:name="fieldName">updatedDate</ac:parameter>
</ac:structured-macro>
</p>
<ac:structured-macro ac:macro-id="09d9b4f1-a87c-4642-a3b8-75a58bc66f30" ac:name="confiform-entry-edit" ac:schema-version="1">
<ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
</ac:rich-text-body>
</ac:structured-macro>

 

2 answers

1 vote
Alex Medved Apr 24, 2019

There is no background process / scheduler in ConfiForms and you need to instantiate the update process elsewhere (CRON using ConfiForms REST API)

Or, as you have mentioned - add the REST API call to ConfiForms API on page load.

Update specific field seems to be appropriate here. You can set the filter to execute update only on the records matching your criteria

Ansar Rezaei Apr 24, 2019

Hi Alex
You always have some advice and I really Appreciate it.

Could you explain it a bit more? I didn't know how to add the REST API call to ConfiForms API on page load?

Ansar Rezaei Apr 24, 2019

Hi

Did you mean something like this?

curl -u admin:admin -X POST "http://192.168.41.239:8090/confluence/ajax/confiforms/rest/update.action?pageId=6555970&f=f1&q=updatedDate:<[now]-60&fv=status:success"
Alex Medved Apr 25, 2019

I don't really know how you can call a curl from a web page... I was more towards using jQuery with something like this

 

<script type="text/javascript">
AJS.toInit(function() {
var xhr = AJS.$.ajax({
url: AJS.params.contextPath + '/ajax/confiforms/rest/update.action?pageId=6555970&f=f1&q=updatedDate:<[now]-60&fv=status:success',
type: 'GET',
timeout: 20000, // 20 sec
success: function (data) {
// handle success
},
error: function (jqXHR, textStatus, errorThrown) {
// handle error
}
});
});
</script>

However, as this will be loaded after the page is rendered then it will show the data from ConfiForms as it was before the update 

 

The best option to do anything like this is to use something like a CRON or another type of scheduler of choice and setup a call to ConfiForms REST API

Ansar Rezaei Apr 25, 2019

Hi

I try to did it manually using an empty form and a register button and an ifttt macro on it, but it show some error. The top form is my main form and the bottom form I used for call Webservice Request.

<ac:structured-macro ac:macro-id="848cb8f1-87c8-4c75-a16a-f7ae12b18adc" ac:name="confiform" ac:schema-version="1">
<ac:parameter ac:name="formName">f1</ac:parameter>
<ac:rich-text-body>
<ac:structured-macro ac:macro-id="6e70de46-02f5-4244-ae5a-f3aeab659475" ac:name="confiform-entry-register" ac:schema-version="1">
<ac:parameter ac:name="formName">f1</ac:parameter>
<ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p>
<ac:structured-macro ac:macro-id="2c376518-07b1-4636-8a00-825f710b511d" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">status</ac:parameter>
<ac:parameter ac:name="fieldLabel">My text field</ac:parameter>
<ac:parameter ac:name="values">false[success=a|error=B|current=C|]</ac:parameter>
<ac:parameter ac:name="type">status</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="da4d3518-caf6-45da-addd-07ccf86a369f" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">updatedBy</ac:parameter>
<ac:parameter ac:name="fieldLabel">Updated by:</ac:parameter>
<ac:parameter ac:name="type">hidden</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="2453f5bc-edf3-49ec-a36d-09cc010f4e76" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">updatedDate</ac:parameter>
<ac:parameter ac:name="fieldLabel">Updated Date:</ac:parameter>
<ac:parameter ac:name="type">datetime</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="c382805e-c34c-4f74-8a46-c63235e4aea4" ac:name="confiform-field-definition-rules" ac:schema-version="1">
<ac:parameter ac:name="condition">updatedDate:&lt;[now]-60</ac:parameter>
<ac:parameter ac:name="values">status=success</ac:parameter>
<ac:parameter ac:name="action">Set value</ac:parameter>
</ac:structured-macro>
</p>
<ac:structured-macro ac:macro-id="4b4e1bc5-9432-48e3-8968-7e37295cce44" ac:name="confiform-ifttt" ac:schema-version="1">
<ac:parameter ac:name="action">Create ConfiForms Entry</ac:parameter>
<ac:parameter ac:name="event">onCreated</ac:parameter>
<ac:parameter ac:name="title">entryId=[entry.id]&amp;updatedBy=[user]</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<ac:structured-macro ac:macro-id="535006ce-b3d9-4698-9356-0db560fb3499" ac:name="confiform-ifttt" ac:schema-version="1">
<ac:parameter ac:name="action">Create ConfiForms Entry</ac:parameter>
<ac:parameter ac:name="event">onCreated</ac:parameter>
<ac:parameter ac:name="title">entryId=[entry.id]&amp;updatedDate=[now]</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<ac:structured-macro ac:macro-id="207991aa-4e6c-4194-8310-bb48ad407b7b" ac:name="confiform-ifttt" ac:schema-version="1">
<ac:parameter ac:name="action">Create ConfiForms Entry</ac:parameter>
<ac:parameter ac:name="event">onModified</ac:parameter>
<ac:parameter ac:name="title">entryId=[entry.id]&amp;updatedBy=[user]</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<ac:structured-macro ac:macro-id="cac9e48a-eecd-4a34-a5dd-15ff7f82e235" ac:name="confiform-ifttt" ac:schema-version="1">
<ac:parameter ac:name="action">Create ConfiForms Entry</ac:parameter>
<ac:parameter ac:name="event">onModified</ac:parameter>
<ac:parameter ac:name="title">entryId=[entry.id]&amp;updatedDate=[now]</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
</ac:rich-text-body>
</ac:structured-macro>
<ac:structured-macro ac:macro-id="90673f38-7f9a-4be6-ad3c-5f46943c1948" ac:name="confiform-table" ac:schema-version="1">
<ac:parameter ac:name="formName">f1</ac:parameter>
<ac:rich-text-body>
<p>
<ac:structured-macro ac:macro-id="89b28b74-64ea-4082-b0a4-bc5f637ff28d" ac:name="confiform-field" ac:schema-version="1">
<ac:parameter ac:name="fieldName">status</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="d9a2031a-caeb-48e9-88d6-5829ab13dc7a" ac:name="confiform-field" ac:schema-version="1">
<ac:parameter ac:name="fieldName">createdBy</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="c90c2b7d-dcd6-4d13-939e-80d103d16c04" ac:name="confiform-field" ac:schema-version="1">
<ac:parameter ac:name="fieldName">updatedBy</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="4e43bb45-b9cc-46c3-9c0a-bf356d704a15" ac:name="confiform-field" ac:schema-version="1">
<ac:parameter ac:name="fieldName">updatedDate</ac:parameter>
</ac:structured-macro>
</p>
<ac:structured-macro ac:macro-id="09d9b4f1-a87c-4642-a3b8-75a58bc66f30" ac:name="confiform-entry-edit" ac:schema-version="1">
<ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
</ac:rich-text-body>
</ac:structured-macro>
<ac:structured-macro ac:macro-id="337954bc-3b58-4c02-8ff5-a38fdf199fcb" ac:name="confiform" ac:schema-version="1">
<ac:parameter ac:name="formName">updatetable</ac:parameter>
<ac:rich-text-body>
<ac:structured-macro ac:macro-id="9e650e74-b652-46f7-a7aa-772416edca50" ac:name="confiform-entry-register" ac:schema-version="1">
<ac:parameter ac:name="registrationButtonLabel">بروزرسانی</ac:parameter>
<ac:parameter ac:name="embedded">true</ac:parameter>
<ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<ac:structured-macro ac:macro-id="dc6b1776-0f55-4ad0-93b5-d423595d713b" ac:name="confiform-ifttt" ac:schema-version="1">
<ac:parameter ac:name="action">WebService Request</ac:parameter>
<ac:parameter ac:name="extras">a2c18f37c29299af8db8230ec35e59cd</ac:parameter>
<ac:parameter ac:name="event">onCreated</ac:parameter>
<ac:parameter ac:name="title">/ajax/confiforms/rest/update.action?pageId=6555970&amp;f=f1&amp;q=updatedDate:&lt;[now]-60&amp;fv=status:success</ac:parameter>
<ac:parameter ac:name="who">GET</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
</ac:rich-text-body>
</ac:structured-macro>

This is my form and I set web service connection without content-type:application/json header in ConfiForms app configuration

It show me this error:

Invalid uri 'http://192.168.41.239:8090/confluence/ajax/confiforms/rest/update.action?pageId=6555823&f=s1&q=updatedDate:<1556192948303-60&fv=status:success': Invalid query

I think there is somthing wrong with my filter

q=updatedDate:<1556192948303-60

Does It has an specific format?

Ansar Rezaei Apr 29, 2019

Hi Alex

Any update?

Alex Medved Apr 30, 2019

Why at all have the ConfiForms IFTTT to use ConfiForms REST API to update the records and not to use specifically designed ConfiForms IFTTT action called "Update ConfiForms entries by filter" !?

As for the filter/query

q=updatedDate:<[now]-60

This makes very little sense actually, as you operate here with timestamps and that means you check the updatedDate to be just 60 milliseconds before now

Alex Medved Apr 30, 2019

As for the "invalid query" error, then please do url encode the < parameter

 

...q=updatedDate:%3C[now]-60&fv=status:success
0 votes
Davin Studer Community Leader Apr 23, 2019

If I understand you correctly it sounds like you are trying to set a field to a specific value when you edit the entry if the last time the record was updated was over ten days ago? If that is so you can use a ConfiForms Rules for Field Definition macro. You would set it to have an "Action to execute" of Set value and set a Condition to look something like this ...

lastUpdated:<[today]-10
Ansar Rezaei Apr 23, 2019

Hi

I have status field with A,B and C values. A is default value and users could change it to B. This value must change to C by user action during 10 days and if It doesn't happen it should be automatically change to A.

I need to execute this action automatically each night or on form/page load and didn't require user action.
I have this condition on ConfiForms Rules for Field Definition macro:

updatedDate:<[now]-864000

 I set last updated value on new field that it's name is updatedDate.

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Posted in Marketplace Apps & Integrations

Demo Den Ep. 4: Continuous Integration with CircleCI & Jira Software

Get ready! Demo Den Episode 4 is coming your way on Tuesday, May 28, 2018 with a Continuous Integration and Delivery special demo. CircleCI Director of Solutions Engineering, Eddie Webb will show us ...

704 views 0 4
Join discussion

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