Fix: Unsorted Custom Fields in case UI bug #2319
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello,
There is a bug when creating case via case creation API.
When creating case via API, user custom fields and template custom fields, all the custom fields together are seems shuffled. example:
test-template.json:
When creating case with case-creation.py (using thehive4py package):
The output case custom fields looks like:
The bug is because the 'caseCf' variable (user custom fields) has order field in each object, and the order value is the order
of lines which in the case-creation.py CustomFieldHelper function (translates to incremental order field in the array when using rest API) starting from 0 ('user-field1' order value is 0, 'user-field2' order value is 1 and so on).
In addition the 'uniqueFields' variable (template custom fields) has order field in object too, the order is which custom field you added first in template starting from 1 (for example in our case 'template-field1' order is 1, 'template-field2' order is 2...)
When sorting them together by order it explains the looks of the screenshot:
user-field1 | order=0
user-field2 | order=1
user-template1 | order=1
user-field3 | order=2
user-template2 | order=2
user-field4 | order=3
user-template3 | order=3
user-template4 | order=4
My solution for this was to 'sortBy' the template custom fields and the user custom fields by '_.order' field in separate, and then concat the Seq together, removing the 'sortBy' after the concation.