Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

recordStorage.GetRecordByUniqueId returns RecordFields in random order #661

Closed
mcl-sz opened this issue Oct 17, 2021 · 3 comments
Closed

Comments

@mcl-sz
Copy link

mcl-sz commented Oct 17, 2021

When using recordStorage.GetRecordByUniqueId, the propery RecordFields return the fields in a diffrent order than on the form.

Reproduction

Lets say i have this code in a controler, where i get the record, update a field and update te status to Approved:

                    viewModel.Entry = _recordStorage.GetRecordByUniqueId(entry ?? Guid.Empty, viewModel.Form);

                    if (isApproved && viewModel.Entry.State != FormState.Approved)
                    {
                        // Update Approve fields
                        foreach(var approveField in viewModel.ApproveFields)
                        {

                            foreach (RecordField recordField in viewModel.Entry.RecordFields.Values)
                            {
                                if (recordField.Field.FieldTypeId == approveField.FieldTypeId)
                                {
                                    recordField.Values.Clear();
                                    recordField.Values.Add(string.Format("{0} at {1} by {2}", DateTime.Now.ToString("d MMMM yyyy", cultureinfo), DateTime.Now.ToString("H:mm"), member.Name));
                                }
                            }

                        }

                        // Update Record
                        _recordStorage.UpdateRecord(viewModel.Entry, viewModel.Form);

                        // Approve Record
                        _recordService.Approve(viewModel.Entry, viewModel.Form);

Than the problem is that the Razor Mail Workflow in the On Approved section is having random ordered recordfields and send the mail with fields in random order.

Expected result

While Record.RecordSet is a dictonary, which has no particular order, i would expect that RecordFields are returned in the formfield order, like in the On Submit -workflow.

Actual result

Record.RecordSet items are in random ordered.

@AndyButland
Copy link

Hi - I can see as you say we're using dictionaries here to expose the field data, so it's possible we strictly shouldn't be able to rely on the order. But that said, I'm not able to replicate this trying to set up an analogous test - I've used similar approval code to what you have here and I find the order of the fields on an email send on submit and on approve to be the same.

Could you confirm what version of Forms you are running please?

@mcl-sz
Copy link
Author

mcl-sz commented Oct 18, 2021

We're using 8.7.6. We found out that de order where the records are in the UFRecordsFields table is also random. recordStorage.GetRecordByUniqueId reads them in the same order as they are stored in de table.

@AndyButland
Copy link

AndyButland commented Jun 26, 2022

Resolved for the next minor releases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants