I've been trying to get 2 custom fields to be added together and comment the outcome in the comment section of the form. This is working when Customfield + 3.95 the output is adding them together and then commenting the correct output. However, we are trying to make the "3.95" a customer field that can be changed depending on what options are selected in the form, So we have changed the code the represent this with a custom field + custom field the outcome is being commented is just the input from the first custom field and the math s not being applied.
This code is working:
This code is not working
(Please note we have tried adding both custom fields with Issue.customfieldname and with the custom field ID and both are not added together correctly.
Further note:
here is the audit log of the automation, it shows as successful and that the equation is commented as written.
Hi @Ethan Bhardwaj -- Welcome to the Atlassian Community!
In addition to the other suggestions offered...
I note your rule is editing an issue field before the attempt to add the comment. Is the comment referencing the field just edited and was that field empty before the edit?
If so, your rule is missing an action to Re-fetch the issue after the edit and before the comment:
When a rule edits an issue, it is updating the data in the Cloud storage and is not updating the data as the rule proceeds. To refresh the data to the current state, add the Re-fetch Issue action to reload the issue before the rule proceeds.
Kind regards,
Bill
Hi @Ethan Bhardwaj, welcome to Atlassian community.
Are you able to provide images of
Edited: I noticed later editions of the original question included this.
TimK
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Ethan Bhardwaj, try small letters. customfield_xxxxx, not customField_xxxxx.
TimK.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Tim,
thanks for the swift reply,
Currently, we have an automation that takes the "remaining balance" from an input field in the form and sets it to a custom number field
We then have another automation that has an If statement so depending on the input selected it will set the second field in this case "fee" to the appropriate number
We then have an automation that will add these custom fields together to comment on the final balance but this is where it is not working.
I hope this information can help.
Ethan
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.
Hi @Ethan Bhardwaj, can you provide the two things I mentioned in my first reply, now over-striked? Including the newly edited formula where you are using small caps.
Also provide the result, i.e. the comment added.
TimK
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Tim Kopperud
no problem, here is the code for commenting an outcome.
The bottom comment happens first this displays the 1st custom field in this case the remaining balance that is inputted in the form. the top comment is supposed to show the 1st custom field + the 2nd custom field which in this case is fee and then comment the result. As you can see it is not adding the field. this field is being set in a radial field
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Ethan Bhardwaj, since it seems you are using this rule for testing, I might recommend another approach for error investigation on smartvalues:
I have created an example rule for trying to reproduce the error:
Mapping of CFs are:
16034 => 10215 Remaining fee
16133 => 10216 Activation fee
This created the following in the log entry when I executed it manually (no errors):
This way we can see where the log actions (LAx) first hit an error. E.g. in your case you can see if its about fetching the value (in LA2) or if it is the formula (in LA3) etc.
Can you try something like this, and post the result?
TimK
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Tim Kopperud ,
Thank you for your response,
As you can see from the tests, the Activation fee is not being set correctly.
The fee is set from a Radio button selection
This Automation sets the radio button selection and adds the relevant fee to the custom field then additional automation then on issue creation comments the sums
As you can see from the XML of the issue raised, the value of the fee has been set to 2.95
I hope this Log helps
- Ethan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Ethan Bhardwaj , try using {{customfield_10037.value}}
TimK
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Ethan Bhardwaj, sorry for my short reply yesterday, I was "PC offline", hence was not able to test accordingly, and replied from mobile. After testing it seems it works without using ".value" syntax.
I do agree with @Bill Sheboy and @Dick that refetching the issue is important when you, within the rule, edit a field value and attempt to use that newly set value later in the same rule.
But when you post this image
I understand you have created a test rule as recommended earlier which is triggered manually and is as simple as possible with no edit or filter, hence you haven't actually edited the issue within the rule when doing this test. Is this correct?
The red line above is where we expect to find a number.
The next image you attached doesn't show this test rule as I cannot see any "Log actions" in it.
Can you provide an image of the test rule where ypu are setting the log actions? Most important to include is the Log action for LA1 (red line above).
TimK
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Good Morning @Tim Kopperud
Thanks for your continued help is appreciated.
Attached is the test automation yet sent to me, I switched it to when a form is created. Both values of the custom fields are defined when the form is filled out, as both the remaining balance and fee need to be entered here. So in this case, as you can see in the XML code the "Activation fee" field is being defined as I have tested with other numbers and the XML reflects this change. I hope this all makes sense.
If you have a solution or a fix I would be grateful.
-Ethan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Ethan Bhardwaj, I don't have the solution yet, but we might get there soon.
Can you, in the test rule (your image above) switch the rule trigger (green step) and replace it with Scheduled trigger? You can replace it by simply delete the existing trigger and add a new one.
In that scheduled trigger:
See my previous image (with all those yellow markings) as an example hwr to configure the scheduled trigger.
Execute the rule manually.
If the audit log still doesn't show any value for LA1 please attach images of:
TimK
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I got the following error when entering the scheduled command you posted above.
I tried both the custom field ID and the name of the custom field itself and have received errors both times.
This is where the issue is being applied in a separate automation the fee is being applied like this, I have added a log action to this automation to check to see if the problem lies here but as you can see from the attached audit log it is being updated correctly, for some reason, this is not being updated when the other automation is trying to add and comment them to the raised form.
- Ethan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Ethan Bhardwaj, the JQL should be
issue = CS-10
By your last image CS-10 seems to be the issue you are testing against, hense this is what we apply to the JQL.
Try this, and test according to my previous reply.
TimK
Answering from mobile.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
One more thing about the Re-fetch Issue action...
When using the Issue Created trigger, that one can fire so quickly that some of the issue data may not yet be available to the rule. This will cause symptoms like empty fields and rule steps not working as expected, possibly even errors in the log.
The fix for this is to always add the Re-fetch Issue action immediately after the Issue Created trigger. This will slow down the rule a bit, reloading the data before the rule continues.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I updated the test automation with audit log reporting and it seemed to work here.
As you can see this has worked when re-fetching the details from the the CS-10 form reference.
Maybe it is what @Bill Sheboy is saying and the trigger is firing too quickly causing it not to capture any data. I have tried editing the automation that does the equation and have the re-fetch data straight after the trigger is activated but I get the same result as previous.
Thanks
Ethan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
When you review the issue details, what do you see in the comment? Please post an image of that view. Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you both this has now worked I have added a 10-second delay after the Trigger into a re-fetch issue data and this has outputted the correct comment for the fields. the audit log also reflects this.
All the best Ethan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Ethan Bhardwaj, great news. Thanks for accepting the answer.
TimK
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ethan,
I have a similar calculation using custom fields.
My calculation has the issue reference in it:
{{#=}} {{issue.customfield_12800}} + {{issue.customfield_12805}} {{/}}
I suspect that if you only use {{customfield_xyz}} the value gets interpreted as a string.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Dick ,
Both the Custom fields are set as Custom Number fields so they shouldn't be Strings looking into the XML code of the form you can see that the fee is being set to the appropriate value and the remaining balance custom field is also the correct input.
So I am uncertain why when using {{#=}}{customfield_xxxx}} + {{customfield_xxxx}}{{/}} is not outputting in this case "27.95"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I suspect the variable you refer to gets the correct type ONLY if it's related to a full object (which the issue is).
I'm calculating the Weighted Shortest Job First (WSJF) using dropdowns and a calculation similar to the one I gave above.
Try it??
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In your own examples, a full reference to the issue yields a correct value. Removing said reference doesn't work.
I really think the reference to the issue is important here.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Dick
we have added the issue. to the custom field ID and we have reviewed the Audit log and have received back the following error "Missing parameter(s) for operator +: 25.0 +"
In this instance, it does not add the "Activation fee" Custom field even though it is being set, as shown in the XML above.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The re-fetch that @Bill Sheboy suggested is essential here. One of your fields is not carrying the value.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Looking at the above log, it's the commenting of the issue (last step) where the codes throws an error.
When commenting, one typically requires an output that resembles more of an html text. You might want to show the newly calculated (and re-fetched!!) content of the field you just edited successfully:
{{issue.customfield_10037}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ah, I see the issue reference worked :)
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.
Hi Tim,
Unfortunately, the change in capitalisation hasn't affected the result.
Ethan
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.