With Confiforms, Create multiple Insight Object from TextArea

Xavier
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 26, 2021

Dear all,

I try to create a small confluence page, which allow creation of one or multiple Insight object depending of value entered in a Custom Field.

This works when I entered only one value, but copy/paste of multi rows return this kind of error:

 

Could not prepare JSON: '{ "objectTypeId": 1, "attributes": [{ "objectTypeAttributeId": 11, "objectAttributeValues": [{ "value": 123456 4523657 }] } ] }'. Invalid format. Expected a ',' or '}' at 150 [character 1 line 7]

 

On My IFTTT integration rules, I use a Create Insight Object, and then on No Format macro the following code:

{
"objectTypeId": 1,
"attributes": [{
"objectTypeAttributeId": 11,
"objectAttributeValues": [{
"value": [entry.mymultivalueareafield.transform(id).asArrayOfKVPairs(key)]
           }]
}
]
}

 

How I can implement that?

thanks in advance.

regards

 

1 answer

0 votes
Alex Medved _ConfiForms_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 27, 2021

Hi

are you using NoFormat or Code macro to wrap (and pass) your Insight Object JSON mapping to ConfiForms?

Also, you have [entry.mymultivalueareafield.transform(id).asArrayOfKVPairs(key)] in the mapping, but shared something else in the error message

As this instruction, when properly used, will produce something like

{"key": "someID", "key": "anotherID"}

Alex

Xavier
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 27, 2021

Dear Alex,

thank you for your quick answer.
Yes, I use a "No Format" macro in the IFTTT macro to store the JSON. And indeed, the error message is strange, I don't understand it. It's like if the tool didn't recognize the line break.

Is there a way to log/ debug such kind of script (i.e console which step by step shows the values...) ?

regards,

Xavier

Alex Medved _ConfiForms_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 27, 2021

The error is actually correct, as 

"value": 123456 4523657

is not a correct JSON

So, your instruction 

[entry.mymultivalueareafield.transform(id).asArrayOfKVPairs(key)]

is incorrect

I suggest to do the following

Create a ConfiForms PlainView and put this expression inside the macro body

See what it produces

Alex

Xavier
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 30, 2021

Dear Alex,

thank you for your post. this product data with blank data instead comma, line break...

will check for correct formatting

regards

Alex Medved _ConfiForms_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 30, 2021

What field type this 

mymultivalueareafield

field actually is?

Alex 

Xavier
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 2, 2021

textarea

Alex Medved _ConfiForms_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 2, 2021

Sorry, I am confused now.. you are talking about textarea in the subject of the ticket, but in your JSON you have something like 

mymultivalueareafield

using transform function... 

What is your question really? How does this textarea field plays here!?

Alex

Xavier
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 3, 2021

So, On my form, I have one field (of type textarea, with the name mymultivalueareafield) on which I would like to entered or copy/paste values, eventually separate by carriage return

So, on the IFTTT, (Create Insight Object), I add a No Format macro, and entered 

{
"objectTypeId": 1,
"attributes": [{
"objectTypeAttributeId": 11,
"objectAttributeValues": [{
"value": [entry.mymultivalueareafield.transform(id).asArrayOfKVPairs(key)]
           }]
}
]
}


Alex Medved _ConfiForms_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 3, 2021

Honestly, I dont understand what are you trying to "transform by id" in text area... this field has no "id"... and is not multi-value (multi-select). 

Something like this might work...

[entry.mymultivalueareafield.replaceCRLFWithBR.split(<br/>).asArrayOfKVPairs(key)]

Alex

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events