MySQL Query for List Field requires refresh everytime

5 posts by 2 authors in: Forums > CMS Builder
Last Post: February 17, 2011   (RSS)

By sidcam - February 15, 2011

I'm using the Membership plug-in on a real estate website.

In the User Accounts section I've created a checkbox field called "internal_agent" to distinguish between internal users (checked/yes) vs members who are just website visitors (unchecked/no). The default state is unchecked.

I am currently building a backend lead management webpage where the users with internal agent status can login and see User Account data for visitors that have been assigned to them by the admin.

To assign visitors to agents, I've created a list field within the User Accounts Section called "assign_agent".

This populates from the following MySQL query:

SELECT fullname, fullname
FROM `<?php echo $TABLE_PREFIX ?>accounts` WHERE internal_agent = '<?php echo $ESCAPED_FILTER_VALUE ?>'

Then on the webpage I display the User Account member's data assigned to the agent this way.

list($accountsRecords, $accountsMetaData) = getRecords(array(
'tableName' => 'accounts',
'where' => 'assign_agent= "'. $CURRENT_USER['fullname'] .'"' ,
'limit' => '10',
));


This works except for one annoying problem...

When I create or go into an existing User Account record the "assign_agent" list field initially populates with the UNchecked member records (exact opposite of what I want to see). It does not correct the field and show the proper data until I've refreshed the list by changing the field designated in the Advanced Filter as the refresh field.

Once the refresh field has been changed, the MySQL data in that list field refreshes and shows up correctly until you open or create another record- then it reverts back to the opposite data again until manually refreshed (again).

Is there something I've done wrong in creating the assign_agent field or is the solution to simply switch the value of the internal_agent checked box so internal-users are unchecked instead of checked?

Thanks

Sid

Re: [sidcam] MySQL Query for List Field requires refresh everytime

By Jason - February 16, 2011

Hi Sid,

What is the field that you are using as a filter in your list field? Let me know as there may be other options.

Thanks
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] MySQL Query for List Field requires refresh everytime

By sidcam - February 16, 2011

At the moment it's the internal_agent check box because it's simple to just toggle twice, but I have tried several other fields thinking that maybe the problem was related to using a field "internal" to the scripting process.

Since you suggested this I just stopped and retried it using both the CMS Builder User Account default email and username fields.

With the email and username fields, the list goes through the refresh process but doesn't actually change (it refreshes to what it started out with- the exact opposite of what I want). When I change it back to the internal_agent check box it behaves as previously mentioned. I have used another checkbox previously (unrelated to the script) and it bahaved just like the internal_agent field.

Sid/St Louis

Re: [sidcam] MySQL Query for List Field requires refresh everytime

By Jason - February 17, 2011

Hi Sid,

If you could fill out a [url http://www.interactivetools.com/support/]2nd Level Support Request[/url] I can take a quick look at what's happening and should be able to give you some better options after that.

Thanks
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/