Create JIRA issue with watchers (confiForms)
Asked by Michael K?ng:

Hey everybody,

I am facing some problems to add watchers during the creation of a JIRA issue by using the IFTTT from confiforms (v3.4.3).

It was running properly in the past, but now it seems not working anymore. I tried to use different kind of values in the "Watchers" field, e.g. username, fullName, e-mail. Nothing works anymore. In the past it works with the username (kuengmi in my case).

Anyone else facing some problems?


Answers:
author: Alex Medved _ConfiForms_
body: Hi

You need to have the same usernames in your Jira and in your Confluence and a username is expected when adding watchers to the issue

Alex

comments: author: Michael K?ng
body: Thanks for the fast answer Alex.

I know, but also if I add the usernames manually to the field watchers, like e.g. kuengmi it wont work.

![2023_06_23_10_13_23_Window.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/264699i09946E37A5E1AA52/image-size/large?v=v2&px=999 "2023_06_23_10_13_23_Window.jpg")

Is this error also connected to the switch to AzureAD, like you work on SUPPORT-5083?

What I don't understand why is it working with Assignee/Reporter, if we using the username which are stored now in a cup.field. I would expect if we have problems by the change to AzureAD, also Assignee/Reporter should make problems.

The code below is still working...

![2023_06_23_10_16_08_Window.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/264700i689CA17DF3B542FB/image-size/large?v=v2&px=999 "2023_06_23_10_16_08_Window.jpg")

If I try the following it wont work....

![2023_06_23_10_17_59_Window.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/264701i0E0BE444444708C1/image-size/large?v=v2&px=999 "2023_06_23_10_17_59_Window.jpg")

But where is the difference to Assignee/Reporter? Alle three fields refer to a user field, where the content where changed by the change to AzureAD, only watch don't work anymore if we refer to cup.field-7.

JIRA users:

![2023_06_23_11_28_35_Window.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/264712iAFB9726BB8D9BB3B/image-size/large?v=v2&px=999 "2023_06_23_11_28_35_Window.jpg")

Sorry for the bad explanation :D


author: Michael K?ng
body: A colleague tested it via REST API and it works, the problem is related to the IFTTT via confiForms...


author: Alex Medved _ConfiForms_
body: How can this be related to ConfiForms only, if ConfiForms uses REST APIs to communicate with Jira!?

And things were working until the recent change with a switch to AzureAD (you have mentioned a private ticket we have in the queue SUPPORT-5083)

Alex


author: Michael K?ng
body: I am not 100% sure, but it still works with Assignee and Reporter if we use the username (kuengmi).

As I follow you, you mentioned that it should still work if I entry e.g. kuengmi in the Watcher field within the IFTTT? This isn't working anymore, but I don't found an explanation.


author: Alex Medved _ConfiForms_
body: What REST API call works for you?


author: Michael K?ng
body: We don't get it running with IFTTT (create JIRA Task - Watcher field WHO) and we don't get it running with a IFTTT web request.

We just get it running with e.g. the network panel from Edge.

![c850616e-4a4a-4cef-b058-87df2aef9e2e.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/264734i7B1E9BA27ACCC317/image-size/large?v=v2&px=999 "c850616e-4a4a-4cef-b058-87df2aef9e2e.PNG")

![dac30fd1-284d-4e5e-946e-295d776e6259.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/264735iD6F5B18E61260536/image-size/large?v=v2&px=999 "dac30fd1-284d-4e5e-946e-295d776e6259.PNG")


author: Alex Medved _ConfiForms_
body: This is exactly the REST API call we are using from ConfiForms


author: Alex Medved _ConfiForms_
body: I still not entirely sure about the change you have done and reported in SUPPORT-5083, but I suspect that ConfiForms now sends over the "new username" (with the email), and not what you try via the REST API

As your users seems to be now identifiable by the email, not usernames (as far as I understand the SUPPORT-5083)


author: Michael K?ng
body: I know, and therefore I don't use the "Watcher" field dynamically anymore. In the past we used a MULTI-USER field, like e.g. \[entry.watcher\], to add watcher to a new generated case.

Because we changed the username structure, I was sure that it will not longer work with this syntax. The problem is now, that it's also not working if I entry a username manually to the "Wtacher" field from the IFTTT.

![2023_06_23_10_13_23_Window.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/264941iC4E3D44FB3239DF8/image-size/large?v=v2&px=999 "2023_06_23_10_13_23_Window.jpg")

That makes no sense for me so far, because it would generate the similar REST API call we was testing via the networkpanel.


author: Alex Medved _ConfiForms_
body: Try looking at the server logs to see what Jira now thinks about the attempt to add a watcher

There should be a warning message from ConfiForms starting as

```
Adding watcher 
```

Alex


author: Marco
body: Hello Alex,  
unfortunatly nothing is beeing logged neither in JIRA nor in Confluence while trying to add a watcher with hardcoded username via IFTTT macro :(

As you stated that the IFTTT internally exactly doeas the same - the question now is why this works via a REST call from client side but not from the IFTTT macro

Do you think it would be helpfull to increase the log levels for confiforms on the Confluence side?

Thanks, Marco  

(2023-06-29: edited)


author: Michael K?ng
body: Dear [@Alex Medved _ConfiForms_](/t5/user/viewprofilepage/user-id/781630) ,

I have done some tests and have a question now. May you can help, I will try to explain...

May assumpion is, that the watcher field of the IFTTT have to be a multi-select User field, or at least you have to forward is as Array to Jira, I think it similar to this: watcher=\[entry.FIELD.asArrayMultiUserPicker\]

At the moment our array with AzureAD look like this: {"name":"michael.kueng@xxxx.de"}, {"name":"marco.leist@xxxx.de"}

Of course, this wont work because we user another user structure in Jira.

To get the right user name structure I have to use a virtual function: \[entry.FIELD.asUserProfile.cup.field-7\]

The first try from my side was: \[entry.FIELD.asUserProfile.cup.field-7.asArrayMultiUserPicker\], but it dont' work.

Anway, may you can answer my questions:

1. If it's possible to use two virtual function combinded?
2. If we use "asArrayMultiUserPicker" the field have to be a user field? If it's not recognized as a user it wont work?


author: Alex Medved _ConfiForms_
body: Hi

You can chain the functions, of course.

"asArrayMultiUserPicker" does not need to have a "user field".

Alex


author: Michael K?ng
body: I have no idea why it's not working....it seems I can't chain the functions.

```
<p class="auto-cursor-target">
<br/>
</p>
<ac:structured-macro ac:macro-id="991d6dc6-d468-4d1e-bbc5-8d4e26ffb4c4" ac:name="confiform" ac:schema-version="1">
<ac:parameter ac:name="formName">user</ac:parameter>
<ac:rich-text-body>
<p class="auto-cursor-target">
<br/>
</p>
<ac:structured-macro ac:macro-id="8f61403c-1db4-4d5d-8736-6d21b1ceee62" ac:name="confiform-entry-register" ac:schema-version="1">
<ac:parameter ac:name="type">Embedded</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p>
<br/>
</p>
<p>
<ac:structured-macro ac:macro-id="1c88684b-e30b-4cd7-8964-226622d5e596" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">user</ac:parameter>
<ac:parameter ac:name="fieldLabel">User</ac:parameter>
<ac:parameter ac:name="type">multiuser</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="be0d297b-efa3-4ee9-a35b-3c719d889e2d" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">userID</ac:parameter>
<ac:parameter ac:name="fieldLabel">User ID</ac:parameter>
<ac:parameter ac:name="type">text</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="c8124c24-1bd3-4088-bc99-f8bf86bc5c16" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">username</ac:parameter>
<ac:parameter ac:name="fieldLabel">Username by cup.field-7</ac:parameter>
<ac:parameter ac:name="type">text</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="4d3cdfb7-318a-4ae1-a56d-f2912ddef60d" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">array1</ac:parameter>
<ac:parameter ac:name="fieldLabel">Array UserIDs</ac:parameter>
<ac:parameter ac:name="type">text</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="53abcda8-ebb9-4880-bf50-e63c252f0aed" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">array2</ac:parameter>
<ac:parameter ac:name="fieldLabel">Array of cup.field-7 content</ac:parameter>
<ac:parameter ac:name="type">text</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="933f4266-42f7-441d-bcb0-fab302bd7a3a" ac:name="confiform-field-definition-rules" ac:schema-version="1">
<ac:parameter ac:name="condition">hasChanged(user):true</ac:parameter>
<ac:parameter ac:name="values">userID=[entry.user]</ac:parameter>
<ac:parameter ac:name="action">Set value</ac:parameter>
<ac:parameter ac:name="actionFieldName">user</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="3ef5b040-dbe0-41fe-ab60-a5f7bc7e7630" ac:name="confiform-field-definition-rules" ac:schema-version="1">
<ac:parameter ac:name="condition">hasChanged(user):true</ac:parameter>
<ac:parameter ac:name="values">username=[entry.user.asUserProfile.cup.field-7]</ac:parameter>
<ac:parameter ac:name="action">Set value</ac:parameter>
<ac:parameter ac:name="actionFieldName">user</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="0f2293ae-77f2-4a5c-9fe8-86683d695f5e" ac:name="confiform-field-definition-rules" ac:schema-version="1">
<ac:parameter ac:name="condition">hasChanged(user):true</ac:parameter>
<ac:parameter ac:name="values">array1=[entry.user.asArrayMultiUserPicker]</ac:parameter>
<ac:parameter ac:name="action">Set value</ac:parameter>
<ac:parameter ac:name="actionFieldName">user</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="38a4639c-b25a-43c0-83a5-396d71a9b6e5" ac:name="confiform-field-definition-rules" ac:schema-version="1">
<ac:parameter ac:name="condition">hasChanged(user):true</ac:parameter>
<ac:parameter ac:name="values">array2=[entry.user.asUserProfile.cup.field-7.asArrayMultiUserPicker]</ac:parameter>
<ac:parameter ac:name="action">Set value</ac:parameter>
<ac:parameter ac:name="actionFieldName">user</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="9ccc3787-5e38-45fd-9dce-349803615ad8" ac:name="confiform-field-definition-rules" ac:schema-version="1">
<ac:parameter ac:name="condition">user:*</ac:parameter>
<ac:parameter ac:name="values">user=[entry._user]</ac:parameter>
<ac:parameter ac:name="action">Set value if empty</ac:parameter>
<ac:parameter ac:name="actionFieldName">user</ac:parameter>
</ac:structured-macro>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p class="auto-cursor-target">
<br/>
</p>
```


author: Michael K?ng
body: Okay, it only works with a Multi-Select field, on a normal text field it won't work. You have tried my example?


author: Marco
body: Hello Alex,

a short addition to better understand Michaels last post:   

We use the app [linchpin user profiles](https://marketplace.atlassian.com/apps/1211696/linchpin-user-profiles?tab=overview&hosting=datacenter) to realize additional custom user profile fields like "location" or "expertise". After we changes the usernames in confluences from SAM Account Name to User Principal name, we mapped the old SAM Account Name to the custom user profile field ".cup.field-7". This way, we only need to adapt our IFTTT macros for creating JIRA Issues a litte bit, w.g. from

**assignee":{ "name":"[entry.assignee]"**   
`(now e.g. marco.leist@sick.de)`

`to`

**`assignee``":{ "``name``":"``[entry.assignee.asUserProfile.cup.field-``7``]"`**(now returns e.g. leistma@sick.de - identical to user in JIRA)

So the point is that with single user fields like "assignee", the chaining with the virtual function `.asUserProfile.cup.field-``7 `works very well - but not combined with the virtual function ".asArrayMultiUserPicker" which is required for JIRA fields that can contain multiple users.


author: Marco
body: Another short update:

We were now successful by replacing

<br />

**"customfield_10200": \[ \[entry.affectedusers.asArrayMultiUserPicker\] \],**

<br />

by

<br />

**"customfield_10200": \[ \[entry.affectedusers.asUsers.transform(asUserProfile.cup.field-7).asArrayMultiUserPicker\] \],**

<br />

within JSON creation code (where "affectedusers" is the name of a confiform multi user field).

Unfortunately, it don't works with the watcher field.  
We would expect that if we could set the watchers within the JSON code, it would work as well, but we haven't found a solution for this so far.

I could imagine that the problems with setting the watcher via JSON are related to <https://jira.atlassian.com/browse/JRASERVER-29304>?


author: Alex Medved _ConfiForms_
body: We dont validate the input as JSON on ConfiForms side and send it as a string as documented in the APIs

Besides, you are saying that direct call to Jira passing the string works for you. Could you update to most recent version of ConfiForms to see if that works any better for you - we have removed the validation for the user (to exist) when collecting "watchers" (obviously, with your changes to new usernames format this was the check that started to fail - as you have usernames in one format, but want to pass to Jira "something else")

Alex


author: Michael K?ng
body: Dear [@Alex Medved _ConfiForms_](/t5/user/viewprofilepage/user-id/781630) ,

Heureka! Without the validation the following string within the watcher field is working for use to add multiple watchers again -\> \[entry.FIELDNAME.transform(asUserProfile.cup.field-7).asList\]

Thanks a lot for your fast and always friendly support! I really appreciate that.

Michael


author: Alex Medved _ConfiForms_
body: So, why it was working (before for you, and others) and why ConfiForms has been checking the usernames to EXIST before sending them to Jira is because of the app link configuration - where the same user names are used in Jira and Confluence... which is now not the case for you (your configurations)

Alex


Tags: confiforms

confluence-server

jira

server