Save a default value to Jira issue when confiforms text field is empty on Submit
Asked by Adrian M:

I'm trying to set a default value to Jira if a confiforms text input is empty. I have tried various ways but it does not save the value of the textbox in Jira if the textbox was empty on submit.

Field macro:

MyInput (text)

Rules macro:

Field name - MyInput

Condition - MyInput:\[empty\]

Execute only on user action - checked (I do not want to show this default value on the form)

Action to execute - set value (or set value if empty)

Values to set - MyInput=No Value Specified

The issue is successfully created in Jira but the value set in the confiforms rules macro does not get saved in the Jira issue.


Answers:
author: Alex Medved _ConfiForms_
body: Hi [@Adrian M](/t5/user/viewprofilepage/user-id/5037760)

Is this a question about the ConfiForms plugin?

Alex

comments: author: Adrian M
body: Hi [@Alex Medved _ConfiForms_](/t5/user/viewprofilepage/user-id/781630) Yes this is about confiforms plugin. I've edited the title to indicate that.


author: Alex Medved _ConfiForms_
body: OK, will add a relevant tag/label as well

However, I dont quite understand this question in the ConfiForms context.

How is this related to a Jira issue you have mentioned? Does your form creates a Jira issue on form submit and all you want is to save back the Jira issue key of the created issue? Is that what you want?

Alex


author: Adrian M
body: The form creates a Jira issue.

The form has a textbox that isn't required to have a user input.

Upon submit, if the user did not input any value in that textbox, then save a default value value to Jira for that field.


author: Alex Medved _ConfiForms_
body: What does it mean
> save a default value value to Jira for that field

Save something into Jira ticket? Updating Jira ticket?

Or when you create a Jira ticket and the value in ConfiForms for some field is empty then something else should be saved to Jira?

Alex


author: Adrian M
body: Only on save. No update.
> Or when you create a Jira ticket and the value in ConfiForms for some field is empty then something else should be saved to Jira?

This.


author: Alex Medved _ConfiForms_
body: So, this question is about how to map a value for some field in JSON mapping?

How is this done now?

Alex


author: Adrian M
body: The mapping is done in the IFFFT macro.

Example:

I have a textbox on the form to capture info. The form field is not required. This form field is mapped to the Acceptance Criteria Jira field.  
Hence if the user submits the form without a value in that form field, then I'd like to save the text "No Value Specified" in the Acceptance Criteria Jira field.

If the user does input a value in the form text box, then that value is saved to the Jira Acceptance Criteria field. \<- I have this working fine.


author: Alex Medved _ConfiForms_
body: I will try again...

So, how do you have this currently in your JSON mapping?


author: Adrian M
body: Mapping as follows:

{ "fields" :

{ "project": { "key": "\[entry.JiraProjectKey\]" },

"issuetype" : { "name": "\[entry.IssueType\]" },

"summary" : "\[entry.Summary.id.escapeJSON\]",

"customfield_14400" : "\[entry.AcceptanceCriteria.escapeJSON\]"

}


author: Alex Medved _ConfiForms_
body: ```
#if(${AcceptanceCriteria})
 "customfield_14400" : "[entry.AcceptanceCriteria.escapeJSON]"      
#else
 "customfield_14400" : "No Value Specified"      
#end
```

See more <https://wiki.vertuna.com/display/CONFIFORMS/Configuring+ConfiForms+IFTTT+actions+and+rules#ConfiguringConfiFormsIFTTTactionsandrules-CreateJiraIssue>

Alex


author: Adrian M
body: Thanks Alex!

I was hoping to keep the logic out of the IFFFT macro and do it using the form macros. But I guess doing and IF/Else statement in the IFFFT macro is the way to go.


author: Alex Medved _ConfiForms_
body: Well, you can set up another IFTTT just before the one that runs the "create Jira issue" and set it up in a way that when AcceptanceCriteria is empty then [you update the record](https://wiki.vertuna.com/display/CONFIFORMS/Configuring+ConfiForms+IFTTT+actions+and+rules#ConfiguringConfiFormsIFTTTactionsandrules-Create(Update)ConfiFormsEntry) and set it's value to "No Value Specified"

Alex


author: Carla Ann Rowland
body: Did you try \[null\] instead of empty?

*** ** * ** ***

comments: author: Adrian M
body: I just did. It didnt work.


Tags: cloud

confiforms

confluence-cloud