ConfiForms IFTTT OnError not triggered after Page Restrictions error
Asked by Ulrik Schoth:

I have a ConfiForms use case where

1. the user starts to create a new page by providing title and target parent page in a ConfiForms form and
2. the new page is created and a page restriction is set to the current user both with IFTTT macros. (The page restriction is set because the page will contain confidential information.)

This works very well if the user has both permissions to create a page and to set page restrictions in the target space.

However, if the user is not permitted to set page restrictions, an error message is displayed in the form: "You are not allowed to manage restrictions on a page '\<name of new page\>'". After closing the form, the new page is still present but without the required page restriction.

I'd like to delete this page with the IFTTT macro and an OnError event but unfortunately the page restrictions error does not trigger the macro.

Am I doing anything wrong or does the IFTTT OnError only react on certain errors?


Answers:
author: Alex Medved _ConfiForms_
body: Hi [@Ulrik Schoth](/t5/user/viewprofilepage/user-id/2108520)

~~You are right, with recent re-development of permissions lifecycle in ConfiForms we have missed this generic functionality~~

Will update the comment... as, things actually work in general. Then only thing that does not work is setting the "silent mode" (aka "Do not report error" parameter on "Page restrictions" managing IFTTTs)

Here is a demo <http://recordit.co/9TENwbNSPD>

And the code

```
<p class="auto-cursor-target"><br /></p><ac:structured-macro ac:name="confiform" ac:schema-version="1" ac:macro-id="da6051b9-f560-4fb5-809d-7be858bf474f"><ac:parameter ac:name="formName">f</ac:parameter><ac:rich-text-body><p class="auto-cursor-target"><br /></p><ac:structured-macro ac:name="confiform-entry-register" ac:schema-version="1" ac:macro-id="915087d3-63bd-4b31-9e3e-36e84496a173"><ac:parameter ac:name="presetValues">p=[entry._page]</ac:parameter><ac:rich-text-body><p><br /></p></ac:rich-text-body></ac:structured-macro><p class="auto-cursor-target"><ac:structured-macro ac:name="confiform-field-definition" ac:schema-version="1" ac:macro-id="71394339-b7c8-4d1a-bd4d-5f394fb028e7"><ac:parameter ac:name="fieldName">p</ac:parameter><ac:parameter ac:name="fieldLabel">p</ac:parameter><ac:parameter ac:name="type">page</ac:parameter></ac:structured-macro></p><p class="auto-cursor-target"><ac:structured-macro ac:name="confiform-field-definition" ac:schema-version="1" ac:macro-id="eeb1beac-ade5-4cfb-9500-8de727cae54c"><ac:parameter ac:name="fieldName">t</ac:parameter><ac:parameter ac:name="fieldLabel">t</ac:parameter><ac:parameter ac:name="type">text</ac:parameter></ac:structured-macro></p><p class="auto-cursor-target"><ac:structured-macro ac:name="confiform-field-definition" ac:schema-version="1" ac:macro-id="283ceeb1-576f-4eb4-9002-4c18e3827f91"><ac:parameter ac:name="fieldName">createdPage</ac:parameter><ac:parameter ac:name="fieldLabel">createdPage</ac:parameter><ac:parameter ac:name="type">hidden</ac:parameter></ac:structured-macro></p><ac:structured-macro ac:name="confiform-ifttt" ac:schema-version="1" ac:macro-id="8c4b8271-0333-4948-a8f7-6b6e025285b6"><ac:parameter ac:name="action">Create Page</ac:parameter><ac:parameter ac:name="extras">[entry.p]</ac:parameter><ac:parameter ac:name="event">onCreated</ac:parameter><ac:parameter ac:name="title">[entry.t]</ac:parameter><ac:rich-text-body><p><br /></p></ac:rich-text-body></ac:structured-macro><p class="auto-cursor-target"><br /></p><p class="auto-cursor-target">--- update record with created page id so we can reference later in onError handler if necessary</p><ac:structured-macro ac:name="confiform-ifttt" ac:schema-version="1" ac:macro-id="113d631c-9c4b-443a-8d98-fe8b684dcbd1"><ac:parameter ac:name="extras3">true</ac:parameter><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;createdPage=[iftttResult_0.id]</ac:parameter><ac:rich-text-body><p><br /></p></ac:rich-text-body></ac:structured-macro><p class="auto-cursor-target"><br /></p><p class="auto-cursor-target">--- restrict page</p><ac:structured-macro ac:name="confiform-ifttt" ac:schema-version="1" ac:macro-id="044bf50e-2874-4fdf-bf73-5b40c773c8a9"><ac:parameter ac:name="extras3">true</ac:parameter><ac:parameter ac:name="action">Restrict Page View</ac:parameter><ac:parameter ac:name="extras">[iftttResult_0.id]</ac:parameter><ac:parameter ac:name="event">onCreated</ac:parameter><ac:parameter ac:name="who">[entry._user]</ac:parameter><ac:rich-text-body><p><br /></p></ac:rich-text-body></ac:structured-macro><p class="auto-cursor-target"><br /></p><p class="auto-cursor-target">-- on error</p><p class="auto-cursor-target">-- delete page</p><ac:structured-macro ac:name="confiform-ifttt" ac:schema-version="1" ac:macro-id="19c7a864-eed0-445a-865f-ac9f429b9de3"><ac:parameter ac:name="action">Delete Page</ac:parameter><ac:parameter ac:name="extras">[entry.createdPage]</ac:parameter><ac:parameter ac:name="event">onError</ac:parameter><ac:rich-text-body><p><br /></p></ac:rich-text-body></ac:structured-macro><p class="auto-cursor-target">--- delete record</p><ac:structured-macro ac:name="confiform-ifttt" ac:schema-version="1" ac:macro-id="a7078cc2-e3fc-4057-8ef3-2e87bf7f9733"><ac:parameter ac:name="action">Delete ConfiForms Entry</ac:parameter><ac:parameter ac:name="event">onError</ac:parameter><ac:parameter ac:name="title">id:[entry.id]</ac:parameter><ac:rich-text-body><p><br /></p></ac:rich-text-body></ac:structured-macro><p class="auto-cursor-target"><br /></p></ac:rich-text-body></ac:structured-macro><p><br /></p><p><ac:structured-macro ac:name="children" ac:schema-version="2" ac:macro-id="723be9a5-0e48-4d7a-be39-3295c8821727" /></p>
```

Alex

comments: author: Ulrik Schoth
body: Hi [@Alex Medved _ConfiForms_](/t5/user/viewprofilepage/user-id/781630)

thanks for your super quick reply! Then I don't need to investigate the problem any further for now and instead look forward to a future fix. :-)


author: Alex Medved _ConfiForms_
body: Updated my answer with little bit more details


author: Ulrik Schoth
body: Hi [@Alex Medved _ConfiForms_](/t5/user/viewprofilepage/user-id/781630)

thanks very much for your example code. I noticed that you are using the record to temporarily store the page ID. I'm trying to achieve the same by using a custom name for the first IFTTTs result (create page). Am I doing this wrong (see code example below)?

I've read the [important note](https://wiki.vertuna.com/display/CONFIFORMS/Configuring+ConfiForms+IFTTT+actions+and+rules) regarding that IFTTT operations are not transactional but I thought that custom names can bridge that gap.

```
<ac:layout>
<ac:layout-section ac:type="single">
<ac:layout-cell>
<p class="auto-cursor-target">
<br/>
</p>
<ac:structured-macro ac:macro-id="20b32d0c-81bd-469d-803d-4c66b24763e4" ac:name="confiform-entry-register" ac:schema-version="1">
<ac:parameter ac:name="hideMetadata">true</ac:parameter>
<ac:parameter ac:name="redirectUrl">https://us-01.swift-wiki.net/pages/viewpage.action?pageId=[iftttResult_mypage.id]</ac:parameter>
<ac:parameter ac:name="formName">mydata</ac:parameter>
<ac:parameter ac:name="registrationButtonLabel">New page</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 class="auto-cursor-target">
<br/>
</p>
</ac:layout-cell>
</ac:layout-section>
<ac:layout-section ac:type="single">
<ac:layout-cell>
<p class="auto-cursor-target">
<br/>
</p>
<ac:structured-macro ac:macro-id="df0c2d97-5518-4c81-862d-d71b44da82e6" ac:name="confiform" ac:schema-version="1">
<ac:parameter ac:name="formName">mydata</ac:parameter>
<ac:parameter ac:name="debugMode">true</ac:parameter>
<ac:parameter ac:name="registrationFormTitle">New page</ac:parameter>
<ac:rich-text-body>
<p>
<ac:structured-macro ac:macro-id="a6c986b8-6086-4f7d-b419-5dcd0284d8c4" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">creator</ac:parameter>
<ac:parameter ac:name="fieldLabel">Creator of new page</ac:parameter>
<ac:parameter ac:name="type">user</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="694a84f4-7cdb-46ff-aed1-04a671150e6c" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">title</ac:parameter>
<ac:parameter ac:name="fieldLabel">Title of page</ac:parameter>
<ac:parameter ac:name="type">text</ac:parameter>
<ac:parameter ac:name="required">true</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="a531a094-b476-4170-8b5e-06c1ff18a349" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">parent</ac:parameter>
<ac:parameter ac:name="fieldLabel">Parent page</ac:parameter>
<ac:parameter ac:name="type">page</ac:parameter>
<ac:parameter ac:name="required">true</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="fe738b6d-20e9-4133-a8e1-5746f0fe561c" ac:name="confiform-field-definition-rules" ac:schema-version="1">
<ac:parameter ac:name="values">creator=[user.name]</ac:parameter>
<ac:parameter ac:name="action">Set value if empty</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="aa4dc959-cf1b-4acb-91bb-4a4fa9e1b71c" ac:name="confiform-field-definition-rules" ac:schema-version="1">
<ac:parameter ac:name="fieldName">creator</ac:parameter>
<ac:parameter ac:name="action">Hide field</ac:parameter>
</ac:structured-macro>
</p>
<ac:structured-macro ac:macro-id="4c36aa49-69a4-455d-8340-83e0e928aaae" ac:name="confiform-ifttt" ac:schema-version="1">
<ac:parameter ac:name="action">Create Page</ac:parameter>
<ac:parameter ac:name="extras">[entry.parent]</ac:parameter>
<ac:parameter ac:name="event">onCreated</ac:parameter>
<ac:parameter ac:name="title">[entry.title]</ac:parameter>
<ac:parameter ac:name="resultName">mypage</ac:parameter>
<ac:rich-text-body>
<span style="letter-spacing: 0.0px;">Content of new page<br/>
</span>
</ac:rich-text-body>
</ac:structured-macro>
<p class="auto-cursor-target">--- set page restriction for current user</p>
<ac:structured-macro ac:macro-id="96b5d558-d770-46dd-9cdc-4788c25116f6" ac:name="confiform-ifttt" ac:schema-version="1">
<ac:parameter ac:name="action">Restrict Page View</ac:parameter>
<ac:parameter ac:name="extras">[iftttResult_mypage.id]</ac:parameter>
<ac:parameter ac:name="event">onCreated</ac:parameter>
<ac:parameter ac:name="who">[entry.creator]</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p class="auto-cursor-target">--- delete record (not needed any longer)</p>
<ac:structured-macro ac:macro-id="f6146160-7084-4acc-811b-ef5f955ce166" ac:name="confiform-ifttt" ac:schema-version="1">
<ac:parameter ac:name="action">Delete ConfiForms Entry</ac:parameter>
<ac:parameter ac:name="event">onCreated</ac:parameter>
<ac:parameter ac:name="title">id:[entry.id]</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p class="auto-cursor-target">--- handle error with page restriction</p>
<ac:structured-macro ac:macro-id="b710c806-212d-424b-a010-c24dc071d288" ac:name="confiform-ifttt" ac:schema-version="1">
<ac:parameter ac:name="action">Delete Page</ac:parameter>
<ac:parameter ac:name="extras">[iftttResult_mypage.id]</ac:parameter>
<ac:parameter ac:name="event">onError</ac:parameter>
<ac:rich-text-body>
<p class="auto-cursor-target">
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p class="auto-cursor-target">
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p class="auto-cursor-target">
<br/>
</p>
</ac:layout-cell>
</ac:layout-section>
</ac:layout>
<p class="auto-cursor-target">
<br/>
</p>
```


author: Alex Medved _ConfiForms_
body: The problem here is that the IFTTTs are per "event"... the results that you have on onCreated event are stored in that event only.

OnError is a completely different event and has OWN context


author: Ulrik Schoth
body: Hi [@Alex Medved _ConfiForms_](/t5/user/viewprofilepage/user-id/781630)

just to ensure that I got it right:

* An IFTTT onCreated macro can share its action result only with other IFTTT onCreated macros.
* An IFTTT onModified macro can share its action result only with other IFTTT onModified macros.
* An IFTTT onDeleted macro can share its action result only with other IFTTT onDeleted macros.
* An IFTTT onError macro can share its action result only with other IFTTT onError macros.
* To share a result between IFTTT macros of different event type one has to store it in a record field.

If this is true I'd suggest to add this information to the ConfiForms Wiki.


author: Ulrik Schoth
body: Hi [@Alex Medved _ConfiForms_](/t5/user/viewprofilepage/user-id/781630)

I have adapted my [previous code](https://community.atlassian.com/t5/Confluence-questions/Re-Re-ConfiForms-IFTTT-OnError-not-triggered-after-Page/qaq-p/1987200/comment-id/237546#M237546) according to your suggestions (see below) and have come across the question: **In which order are the IFTTT macros executed in case of an error?**

Background: I want to delete the record *always* , not only in case of an error. I had assumed that changing the event from OnError to OnCreate (in IFTTT macro with action = Delete ConfiForms Entry) and moving the macro to the last position in the ConfiForms Form macro body would ensure that it is executed in both normal and error cases. I know the note regarding the execution order on this [page](https://wiki.vertuna.com/display/CONFIFORMS/Configuring+ConfiForms+IFTTT+actions+and+rules), but assumed that after completion of the *error handling*, the processing of the macros is continued at the point where it was interrupted by an error.

However, this assumption seems to be wrong. As a solution, I have now used two macros to delete the record, one for the normal case and another one for the error case.

Would you suggest another solution?

```
<ac:layout>
<ac:layout-section ac:type="single">
<ac:layout-cell>
<p class="auto-cursor-target">
<br/>
</p>
<ac:structured-macro ac:macro-id="4aabdff8-f509-41d3-9c43-a519cde523c2" ac:name="confiform-entry-register" ac:schema-version="1">
<ac:parameter ac:name="hideMetadata">true</ac:parameter>
<ac:parameter ac:name="formName">mydata</ac:parameter>
<ac:parameter ac:name="registrationButtonLabel">New page</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 class="auto-cursor-target">
<br/>
</p>
</ac:layout-cell>
</ac:layout-section>
<ac:layout-section ac:type="single">
<ac:layout-cell>
<p class="auto-cursor-target">
<br/>
</p>
<ac:structured-macro ac:macro-id="df0c2d97-5518-4c81-862d-d71b44da82e6" ac:name="confiform" ac:schema-version="1">
<ac:parameter ac:name="formName">mydata</ac:parameter>
<ac:parameter ac:name="debugMode">true</ac:parameter>
<ac:parameter ac:name="registrationFormTitle">New page</ac:parameter>
<ac:rich-text-body>
<p>
<ac:structured-macro ac:macro-id="694a84f4-7cdb-46ff-aed1-04a671150e6c" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">title</ac:parameter>
<ac:parameter ac:name="fieldLabel">Title of page</ac:parameter>
<ac:parameter ac:name="type">text</ac:parameter>
<ac:parameter ac:name="required">true</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="a531a094-b476-4170-8b5e-06c1ff18a349" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">parent</ac:parameter>
<ac:parameter ac:name="fieldLabel">Parent page</ac:parameter>
<ac:parameter ac:name="type">page</ac:parameter>
<ac:parameter ac:name="required">true</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="07ce63cd-92aa-4789-a531-4f163f59ed87" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">createdPage</ac:parameter>
<ac:parameter ac:name="fieldLabel">createdPage</ac:parameter>
<ac:parameter ac:name="type">hidden</ac:parameter>
</ac:structured-macro>
</p>
<ac:structured-macro ac:macro-id="4c36aa49-69a4-455d-8340-83e0e928aaae" ac:name="confiform-ifttt" ac:schema-version="1">
<ac:parameter ac:name="action">Create Page</ac:parameter>
<ac:parameter ac:name="extras">[entry.parent]</ac:parameter>
<ac:parameter ac:name="event">onCreated</ac:parameter>
<ac:parameter ac:name="title">[entry.title]</ac:parameter>
<ac:parameter ac:name="resultName">mypage</ac:parameter>
<ac:rich-text-body>
<span style="letter-spacing: 0.0px;">Content of new page<br/>
</span>
</ac:rich-text-body>
</ac:structured-macro>
<p class="auto-cursor-target">
<br/>
</p>
<p class="auto-cursor-target">--- update record with created page id <span style="letter-spacing: 0.0px;">so we can reference it later in onError handler if necessary</span>
</p>
<ac:structured-macro ac:macro-id="105d44a6-9c41-4f38-ab82-fbf446649f44" ac:name="confiform-ifttt" ac:schema-version="1">
<ac:parameter ac:name="extras3">true</ac:parameter>
<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;createdPage=[iftttResult_mypage.id]</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p class="auto-cursor-target">
<br/>
</p>
<p class="auto-cursor-target">
<span style="letter-spacing: 0.0px;">--- set page restriction for current user</span>
</p>
<ac:structured-macro ac:macro-id="2affebf8-1ef9-4b8e-ba05-31ac50630506" ac:name="confiform-ifttt" ac:schema-version="1">
<ac:parameter ac:name="action">Restrict Page View</ac:parameter>
<ac:parameter ac:name="extras">[iftttResult_mypage.id]</ac:parameter>
<ac:parameter ac:name="event">onCreated</ac:parameter>
<ac:parameter ac:name="who">[entry._user]</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p class="auto-cursor-target">
<br/>
</p>
<p class="auto-cursor-target">--- delete record (normal case)</p>
<ac:structured-macro ac:macro-id="f6146160-7084-4acc-811b-ef5f955ce166" ac:name="confiform-ifttt" ac:schema-version="1">
<ac:parameter ac:name="action">Delete ConfiForms Entry</ac:parameter>
<ac:parameter ac:name="event">onCreated</ac:parameter>
<ac:parameter ac:name="title">id:[entry.id]</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p class="auto-cursor-target">
<br/>
</p>
<p class="auto-cursor-target">
<span style="letter-spacing: 0.0px;">--- handle error with page restriction</span>
</p>
<p class="auto-cursor-target">
<span style="letter-spacing: 0.0px;">-- delete page</span>
</p>
<ac:structured-macro ac:macro-id="4ad085b0-81d2-466d-a74e-1596fcae1897" ac:name="confiform-ifttt" ac:schema-version="1">
<ac:parameter ac:name="action">Delete Page</ac:parameter>
<ac:parameter ac:name="extras">[entry.createdPage]</ac:parameter>
<ac:parameter ac:name="event">onError</ac:parameter>
<ac:rich-text-body>
<p class="auto-cursor-target">
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p class="auto-cursor-target">
<span style="letter-spacing: 0.0px;">-- delete record (error case)</span>
</p>
<ac:structured-macro ac:macro-id="6313ccba-5889-4dbe-a32c-9b6414361cd2" ac:name="confiform-ifttt" ac:schema-version="1">
<ac:parameter ac:name="action">Delete ConfiForms Entry</ac:parameter>
<ac:parameter ac:name="event">onError</ac:parameter>
<ac:parameter ac:name="title">id:[entry.id]</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p class="auto-cursor-target">
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p class="auto-cursor-target">
<br/>
</p>
</ac:layout-cell>
</ac:layout-section>
</ac:layout>
<p class="auto-cursor-target">
<br/>
</p>
```


author: Alex Medved _ConfiForms_
body: Well, the assumption is wrong, IFTTTs are processed sequentially one by one matching the event and condition.

And in the order your have put them in the form configuration (definition)

When the IFTTT fails - processing of the IFTTTs for this event/condition aborts and another event is initiated - which executes onError IFTTT errors if any

Hope it helps

Alex


author: Ulrik Schoth
body: That helps understanding. Thanks a lot.

Best regards  
Ulrik


author: Alex Medved _ConfiForms_
body: And you are absolutely right, this needs to be explained better in the documentation

Probably with some (flow) diagrams, as these are easier to read and understand.

Will be focusing on that


Tags: confiforms

confluence-server

server