Searching all entries to a form via views or some other way

By: Daveed Flexer | Asked: 12/09/2022
ForumsCategory: Code HelpSearching all entries to a form via views or some other way
Daveed Flexer asked 1 year ago
Hello, Trying to do the following Searching in all entries submitted to a form. If (a field is the same in two entries)
  • Look at another field in two entries and 
  • Do some math between the two entries
  • Look at the result of this math.
Looked at various snippets and shortcodes but they all seem to be within one entry not between entries. Anyone deal with a similar challenge? Daveed
1 Answers
Best Answer
Bobby Clapp answered 1 year ago
The best option you might have without custom code would be this: [frm-math] [frm-field-value field_id=x entry="x"] - [frm-field-value field_id=x entry="x"] [/frm-math]
Daveed Flexer replied 1 year ago

Thanks for taking a look, but how would I do this generally?

That is without knowing in advance what the entry is?

I need to both compare the values of one field and then do the math between two other fields in two different entries, without knowing in advance what entries these are.

Bobby Clapp replied 1 year ago

What is your picture of how this would work? Or what is the expected workflow to get to the point of the need for the calculation?

Daveed Flexer replied 1 year ago

<p><p>Users chooses a 'case number' and enter a bunch of data including a 'price'.</p><p>If the 'case number' is the same the View will display the differential between all the values entered in the 'price' field.</p><p>It doesn't need the original value. It can be displayed anywhere the admin can see it - A private View, the Entries page what have you.</p><p>After not having much luck with Views, I am now looking into getting the array of all the entries and see if i can do something there.</p></p>

Bobby Clapp replied 1 year ago

Do you have anything public to share that I could get a little more insight out of? The description doesn't quite allow me to wrap my head around it. You can email me if it needs to remain semi-private ([email protected]).

Daveed Flexer replied 1 year ago

Hi,

Prefer to keep this public.

https://i.postimg.cc/L8htM3rg/form-results.jpg

Here is a screen cap; The view or the custom page would show the Case Number and the Difference between the two values.

Is that clearer?

Bobby Clapp replied 1 year ago

This helps. Thanks for that image. So then is it possible that a case can an undefined number of values or is it always the 2 values?

Daveed Flexer replied 1 year ago

Yes, only two per case.

(Anything more than 2 will be an error & can be ignored. Not sure how to check for this error, but that's a less important item)

Daveed Flexer replied 1 year ago

These submissions can be within a longer period of time, not in consecutive days, with other submissions between them.

Bobby Clapp replied 1 year ago

So there are only 2 values that matter per case. But then multiple submissions for the same case can occur, if I'm following correctly?

So what 2 values of all submissions within a case matter (just max and min or something else?)?

Daveed Flexer replied 1 year ago

Only two submissions per case;
The value of "Settlement" can be any number.
The only things that matters to us is settlement_1 - settlemtn_2 = result.
The view needs to show case_number and result

We can assume that more than 2 submissions per case is not allowed.

Bobby Clapp replied 1 year ago

Let us try this then:

[frm-math] [frm-stats id=x type=maximum 25="[case_field_id_here]"] - [frm-stats id=x type=minimum 25="[case_field_id_here]"] [/frm-math]

25 should also be the case field id. the only difference is the value will be dynamic using brackets [25] around the actual field id of your form for the case field. This is presuming that there is always a different as well. Also, presuming this will display in a view.

Daveed Flexer replied 1 year ago

Thank you Bobby, but I am getting no result - perhaps I am not understanding the logic here.
What I am looking for is;
> Check if field id#8 (case number) is the same in two entries
> If it is the same - look at the value in field #10 (settlement) for these two entries - Rows
> substract one from the other and output the result in the view.

Thanks

Bobby Clapp replied 1 year ago

Ok. My last post was my attempt at exactly that. Let me work it out in a test environment when I get a moment and we'll see if it works the way I'm thinking. If it does, I'll share that with you.

Daveed Flexer replied 1 year ago

"Oops! That page can’t be found."

Daveed Flexer replied 1 year ago

Case is ID 8
Settlement is ID 10
Where am I wrong?
[frm-math] [frm-stats id=10 type=maximum 8="[8]"] - [frm-stats id=10 type=minimum 8="[8]"] [/frm-math]

Daveed Flexer replied 1 year ago

Thank you Bobby,

I was using a lookout field, for the case number. That's why it wasn't working.
Sorry about that.

When I switched to a regular field it worked! Thank you.

Daveed

Bobby Clapp replied 1 year ago

Hmm. I'm using lookup and it is working fine.

https://postimg.cc/mc97FR0R

Daveed Flexer replied 1 year ago

V_curious
https://postimg.cc/rzQM4NbX
https://postimg.cc/YhGZSNBx
Perhaps a setting on the lookup field?

Bobby Clapp replied 1 year ago

Can you share screenshot of entries?

Daveed Flexer replied 1 year ago

Of course: https://postimg.cc/9DKwPhD9

Bobby Clapp replied 1 year ago

Seems to me it should work with lookup as it is, unless if for that specific entry, the field values have not been updated after adding/removing fields.

Daveed Flexer replied 1 year ago

This is true for all entries including new ones.

When I build this in production, I will try with the lookup field first. Perhaps it's the data, or something else.

I want to thank you very much for the help. It's been a while since I worked with some of the new features of Views. I was in the right direction but the 'results' setup was the key.

Once I get paid for this task I will make sure to visit your web site 😉
I will also keep you mind should I require some Formidable Pro customization for a specific project.

All the best

Daveed Flexer replied 1 year ago

@dgodfather

Hi Bobby thanks to you I have made some very good progress but I am stuck with one issue.
Could I ask you? Or should I start another thread?

Bobby Clapp replied 1 year ago

Start a new one. Particularly if it doesn't relate specifically to this issue. This one is pretty lengthy.

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right