Confiforms: String Functions (e.g. substring) when setting values
Asked by Dan:

New to Confluence - so thanks in advance for any info (or redirection to documentation) that anyone can provide.

When setting values using **Confiforms Rules for Field Definition**, how can I perform string functions? Is there any documentation?

e.g. in my Values to Set:

IssueDescription=\[entry.original_description\]

<br />

I want to perform a substring, possibly using regular expressions, on the original description.

Thanks again!


Answers:
author: Alex Medved _ConfiForms_
body: Hi [@Dan](/t5/user/viewprofilepage/user-id/5293201)

You can see what functions are available in ConfiForms here - <https://wiki.vertuna.com/display/CONFIFORMS/Virtual+functions>

Alex

comments: author: Dan
body: Thanks - it seems that the string manipulation functions are very minimal? Any thoughts on how I could readily extract the third word or phrase from the below string using virtual functions?

```
|Foo|Bar|Bah - I want this piece|Bat|
```

Thanks again!


author: Alex Medved _ConfiForms_
body: You can always have a custom call to a [JavaScript function](https://wiki.vertuna.com/display/CONFIFORMS/ConfiForms+Field+Definition+Rules#ConfiFormsFieldDefinitionRules-RuncustomJavaScript) if you are using the server/dc version and JavaScript support is not disabled by your admins

Here is a demo with "minimal string manipulation functions" - <http://recordit.co/jEk8c627Hs>

Alex


author: Dan
body: Yes, I'm exploring that front too. The string manipulation part is easy, but the impediment I'm hitting on that side is that I don't know how to set all types of ConfiForms Form Field Definitions from javascript. I can set (and query) using:

```
AJS.$('#' + formId).find('#i_fieldToUpdate').val(valueToSet)
```

The above works for "text" and "textarea" field types, but the val() function seems to not work for the "Jira Issue" or "Dropdown" types. Which is ultimately what I'm trying to get to. Is there a list of AJS javascript functions and what they return for each field type? Or am I taking the wrong route there and there's a better javascript way?

Thanks yet again!

ps. I can't follow the recordit dot co link from inside work, but I'll check it out later.


author: Alex Medved _ConfiForms_
body: You can use cfSetValue function as explained in <https://wiki.vertuna.com/display/CONFIFORMS/ConfiForms+Field+Definition+Rules#ConfiFormsFieldDefinitionRules-RuncustomJavaScript>


author: Dan
body: Third impediment: cfSetValue, cfSetValueWithEventPropagation, cfAddFieldRequired, etc. absolutely do not work :D. I have a ticket in with our Atlassian tooling group to see what's up. Thanks again for all your suggestions and time!


author: Alex Medved _ConfiForms_
body: The only reason I can think of functions "absolutely do not work" is that you are using some old version of ConfiForms plugin or your admins have disabled support for JavaScript functions

Alex


author: Dan
body: There's always a non-zero chance it's user error - and that would be the preferred reason by far.


author: Dan
body: Follow-up: Our production version of ConfiForms is indeed old - like positively ancient. Enablement is currently moving a more current version through performance acceptance testing and the code (and everything else discussed above) works great in the PAT environment. Thanks for your help :)


Tags: confiforms

confluence-server

server