Copy Value From Field to Field post function
I was trying to make a postfunction that copies the due date to the end date
but only when the end date field is empty
because they may be different, when they are different they should not copy.
all of these are custom fields
help!!
You seem to be using a very old version of JMWE. In more recent versions, you would have a simple checkbox to check: "Copy only if not set"
If you don't want to update JMWE, you can use the following conditional code:
issue.get("customfield_12345") == null
where customfield_12345 is the field ID of your End Date custom field (see https://confluence.atlassian.com/jirakb/how-to-find-id-for-custom-field-s-744522503.html)
yes i am using an old version, with jira 7.0.4 we arent upgrading in the short term, so i used the lined but still giving me error
see attachment:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I believe this latest error has nothing to do with the conditional execution script. It's easy to check: just uncheck "only if condition is true".
If you look inside the Jira logfile (atlassian-jira.log), you'll find the full error, accompanied by a stack trace. Can you post them here? My guess is that the two fields are incompatible. What is the type of the End date field?
This would not happen with JMWE 5.x, which handles conversion between incompatible field types (among many other new features). Note that JMWE 5 is fully compatible with Jira 7.0.4...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
the post function with out any condition works perfectly
on the other hand:
"End date" is a "date picker" field, while "Due date" is a "date" field
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok, I found the issue. The conditional execution script should be:
issue.get("customfield_11204") == null
You had forgotten the "customfield_"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
it's working
haha! thank you, that was desperating
thanks again!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
As per the docs you have to *return true or false* for the condition to proceed or fail.
The post-function is executed only if the written condition evaluates to true
or a Groovy truthy.
You can quickly test your written script against any issue using the script tester tool.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
if(issue.getCustomFieldValue(end date)) {
return false;
} else {
return true;
}
This should do the trick.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
share your complete code
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
this is it:
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.component.ComponentAccessor;
CustomField cf = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("End date");
if (issue.getCustomFieldValue(cf) == null)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
if (issue.getCustomFieldValue(cf) == null) {
return true;
} else {
return false;
}
Add the above snippet in your code.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Shouldn´t the last line use issueObject instead of issue?
Or use the wrapper with issue.get("End date") - but you shouldn´t fix those two...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Trust you are doing well!
I'm here again for you help.
I have a requirement to make with Date and Time field on Request forms.
The Date should be mandatory and Time should be optinal for Date and Time field.
I have used field required validator with these conditions.
!!(issue.customfield_10042 ? new Date(issue.customfield_10042) : null)
! issue.customfield_10042
But both didn't go well.
Hope you have the solution for It.
Thanks In advance for the help,
Regards,
Ajay
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Ajay Goud Gaddam ,
Is this a regular Date/Time Picker custom field? In that case, I don't believe what you're trying to achieve is possible.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks @David Fischer for your response.
Yes, it Date/time picker custom field! we need only date should be mandatory in the create screen.
Thanks again.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @David Fischer ,
Could you please help me here,
I have added a JMWE postfunction to In progress status (Allowed all statuses to transition to this status) to increament the field value with the ticket transitioned to this status.
But here i want to the increment field value only if the status transitioned from closed or resolved I have used conditional execution as below
{{ issue.transition.from_status.name == "Closed" }} or {{ issues.transition.from_status.name == "Resolved" }}
But here the value of the field is increasing even if we transitions from any other statuses as well not only from Closed and resolved.Will you please assist me to pass the condition if last status was Closed or Resolved.
Thanks in advance for your help,
Regards,
Ajay
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I assume you're on Jira Cloud, correct? In that case, the correct conditional execution expression should be:
{{transition.from_status == "Closed" or transition.from_status == "Resolved"}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.
Register NowOnline forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.