How do I save a ConfiForm field in all caps no matter what case it's entered in?
Asked by Kathleen Janiszewski:

I have rule on a ConfiForm field to run custom Javascript, but it's still saving the text as entered. I'm using \[entry.field\].trim().toUpperCase().


Answers:
author: Alex Medved _ConfiForms_
body: Hi

Take a look at this example

<http://recordit.co/7ZQ4MuZCS9>

And complete configuration as a storage format

```
<ac:structured-macro ac:macro-id="a826c86f-4550-458f-af77-faf271097491" ac:name="confiform" ac:schema-version="1">
<ac:parameter ac:name="formName">f</ac:parameter>
<ac:rich-text-body>
<ac:structured-macro ac:macro-id="2bd79826-69a1-4490-a198-40584be29157" 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="0c1d49c3-0dbd-4c53-88d4-c4aa733230de" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">field</ac:parameter>
<ac:parameter ac:name="fieldLabel">field</ac:parameter>
<ac:parameter ac:name="type">text</ac:parameter>
</ac:structured-macro>
</p>
<ac:structured-macro ac:macro-id="b857eb23-9d0b-4b7e-8617-20b0734d5f0c" ac:name="confiform-ifttt" ac:schema-version="1">
<ac:parameter ac:name="condition">!field:[empty]</ac:parameter>
<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;field=[entry.field.upperCase]</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<ac:structured-macro ac:macro-id="e2670171-a94b-4e33-b843-a2799b0214f6" ac:name="confiform-ifttt" ac:schema-version="1">
<ac:parameter ac:name="condition">!field:[empty]</ac:parameter>
<ac:parameter ac:name="extras3">true</ac:parameter>
<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;field=[entry.field.upperCase]</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
</ac:rich-text-body>
</ac:structured-macro>

```

Hope it helps

Alex

comments: author: Kathleen Janiszewski
body: Alex,

That's a good idea, but it doesn't work, because I already have another IFTTT macro with an onCreated event. Now I get the error: "'Title' is required to be set," even though it's already set.

I'll try some other things.

Thank you.

-Kathleen


author: Kathleen Janiszewski
body: Alex,

I was able to fix my problem by relying on the fact that the filter.action is case insensitive, so my query returns the correct entryId for the query on title:${title}. In the form the title is 'intern', which matches 'INTERN.' Then using the entryId on the save.action REST API call, I set title=${title}, then it becomes "INTERN" in ConfiForm field.

I know that once the bug on the filter.action is fixed, it won't work anymore. I'll have to doument the heck out of this one.

Thank you.

-Kathleen


author: Alex Medved _ConfiForms_
body: Not sure how that is related to the original question, but fine

PS, you can always filter by specific case

```
myfield.upperCase:[entry.myfield.upperCase]
```

Alex


author: Kathleen Janiszewski
body: Alex,

That's important!  
In my case, title is all caps, but the data stored in it may or may not be. However, what I'm telling you is that in this scario, "iNtErN" is what is in the ConfiForm, yet the filter.action matches it on 'INTERN'. What I'm staying is that it's case insensitive, even though it should be case sensitive. IMHO, that's a bug. However, I'm banking on that bug. If Confluence fixes the bug, then my code won't work. The above may keep that from happening. See this part of my code below:  

```


 let title = encodeURIComponent("[entry.title.upperCase.trim()]");
...

 let checkURL = `${CONFI_BASE_URL}/filter.action?pageId=${TRACK_FORM_PAGE_ID}&f=${TRACK_FORM_ID}&q=title:${title}&limitFields=none`;
```

Thanks again.

-Kathleen


author: Alex Medved _ConfiForms_
body: Hi

This "filter.action" endpoint works as ConfiForms filtering engine by default, matching values in a case insensitive manner, unless you want to do something like a regular expression matching (see matches function in <https://wiki.vertuna.com/display/CONFIFORMS/Virtual+functions>)

However, we will add a flag/parameter to the mentioned API to make the filtering case sensitive when needed. This will be available in the upcoming 3.5.5 version

Alex


author: Kathleen Janiszewski
body: Alex,

This is great news! I've already built my code around this issue, and actually just finished up the last issue having to do with it yesterday afternoon. It's still great news!

Thanks again!

-Kathleen


Tags: confiforms

confluence-server

server