Working with Multiple Resources Types

Support for our integrated Contact Manager, Calendar, and Project Tracker.
SeedCode Staff
SeedCode Staff
Posts: 475
Joined: Wed Jan 02, 2013 11:47 am
PostPosted: Tue Mar 26, 2013 1:49 pm
With a few modifications, you can provide your users with a simple tool that lets them decide what values to use for the column headers on the Schedule view.

Before you make any changes to your file, back it up. Do not proceed until you have done this!

NOTE: The modifications described in this article affect both the Schedule and Grid view similarly (a column on the Schedule view is equivalent to a row on the Grid view). For clarity, I'll refer only to the Schedule view.


Section I: Dynamic column headers

1. Create a value list for each type of resource. For example:

Rooms
Teachers
Levels

2. Create another value list whose values are the actual names of the above value lists. We'll call this one "ResourceTypes".

3. Create a global text field in the CalendarInterface table called "ResourceTypeGlob".

4. Place the "ResourceTypeGlob" field on the Settings panel in the sidebar on the Calendar layout, format it as radio buttons, and assign it the "ResourceTypes" value list. Set up an "OnObjectModify" script trigger on that field to run the "Run Resource Filter" script. (see attached image)

5. Somewhere toward the beginning of the "Upon Opening" script, add a Set Field step to assign the CalendarInterface::ResourceTypeGlob field a default value of one of the value list names (we'll use "Rooms" for this example).

6. In the "Load Resources" script, you'll see that the first script step populates the $sc_Resources variable by the following calculation:

ValueListItems ( Get ( FileName ) ; "Resources" )

Change it to this:

ValueListItems ( Get ( FileName ) ; CalendarInterface::ResourceTypeGlob )

This tells the script to populate the column headers on the Schedule view with the value list that the user has selected.

7. In the "Load Filtered Resources" script, replace this step:

Set Variable [$$sc_ResourceList; Value:CalendarInterface::FilterGlob_3]

With these two steps:

Set Variable [$sc_Resources; Value:ValueListItems ( Get ( FileName ) ; CalendarInterface::ResourceTypeGlob )]
Set Variable [$$sc_ResourceList; Value:FilterValues ( $sc_Resources ; CalendarInterface::FilterGlob_3 )]


Section II: Data Entry

1. Open an event in the Event Details popup window, go into layout mode, and go to one of the unused tabs. Draw a field object and associate it with the Resource field. Format the field as radio buttons and assign it one of your resource-type value lists (Rooms). Then repeat that process for each of your other resource-type value lists (Teachers and Levels). So you'll end up with three instances of the Resource field, each associated with a different value list. Label each instance accordingly, and name the tab you're on "Resources". (see attached image)

2. If the Resource field still appears on the "Main Info" tab of your Event Details layout as an edit box or drop-down list, you should remove it to avoid confusion, because from now on the Resource field will contain a list of return-separated values.

3. If in your solution you are storing different resource types in separate fields and you would like to involve them all in rendering events on the Schedule view, simply set the Resource field to auto-enter by calculation the following*:

List ( YourTable::Room ; YourTable::Teacher ; YourTable::Level )

*Where Room, Teacher and Level are separate data fields in your events table.

Be sure to uncheck the "Do not replace existing…" box in the Options dialog.

3a. If you use this "separate fields" scenario, there is one more set of scripting modifications you'll need to make in order to use drag-and-drop to move events between resources on the Schedule view. Drag-and-drop will appear to work at this point (the event will move to the correct new column because the Resource field will have been updated), but don't be fooled. The actual data fields (Room, Teacher and Level) will not have been updated. To fix this problem, open the "Create Edit Delete Event…" script and look within the If [not IsEmpty ($sc_Resource)] nest, immediately following the "This set field includes support for multiple resources…" comment. Disable the "Set Field By Name" step and add three new "Set Field" steps here to update the Room, Teacher and Level fields directly, and wrap each in an If [] statement to determine whether the value associated with the target column appears in the value list that is associated with that field. You can copy the calculation code from the original "Set Field By Name" step, and you only need to change the field that is referenced in the first line (r = YourTable::Room, r = YourTable::Teacher and r = YourTable::Level).




Section III: Filtering

1. To enable filtering based on your multiple value lists, go to the Filters > Resources tab panel in the sidebar and associate the FilterGlob_3 field with the "Rooms" value list.

2. Duplicate that field object and associate the copy with the "Teachers" value list, and then do the same for "Levels". So you'll end up with three instances of the FilterGlob_3 field, each associated with a different value list. Label each instance accordingly.

3. Format these field objects as checkboxes (or popup-menus, if the lists are too long), and resize them as necessary.

multiple_resources_comp.png
Interface changes
multiple_resources_comp.png (158.61 KiB) Viewed 34364 times


Section IV: Going further...

With lots of resources you may only want to see those that are actually used in the found set of events. To restrict the resources this way (in both the column headers on schedule view and in the check boxes for the different resource-type filters) make these additional changes:

1. Create three new text fields in the CalendarInterface table: "vl_1", "vl_2" and "vl_3", and one new global number field called "FilterResourcesGlob".

2. Create three new value lists called "Rooms Filtered", "Teachers Filtered" and "Levels Filtered". Set them up to "Use values from field" from CalendarInterface::vl_1, CalendarInterface::vl_2 and CalendarInterface::vl_3, respectively. Use these new value lists for the filter-field check boxes.

3. Edit the "Load Resources" script so it looks like this:

Load_Resources.png
The updated "Load Resources" script
Load_Resources.png (144.64 KiB) Viewed 34283 times


Here's the code you'll need to set that $all_resources variable:

Code: Select all
ExecuteSQL (
"SELECT \"Resource\" FROM \"SampleEvents\" where \"zscTimestampStartCalcNum\" Between " & $start & " and " & $end &
"Union
SELECT \"Resource\" FROM \"SampleEvents\" where \"zscTimestampEndCalcNum\" Between " & $start & " and " & $end &
"Union
SELECT \"Resource\" FROM \"SampleEvents\" where \"zscTimestampStartCalcNum\" < " & $start & " and \"zscTimestampEndCalcNum\" > " & $end ; "!~!" ; "¶" )


4. Make a toggle switch using the "FilterResourcesGlob" global number field on the "Settings" panel so your users can turn this feature on and off.

That's it! Enjoy!
Attachments
multiple_resources_4.png
Change to the "Create Edit Delete Event…" script
multiple_resources_4.png (131.89 KiB) Viewed 33485 times
Last edited by jeffalmquist on Wed Mar 12, 2014 11:41 am, edited 2 times in total.
Posts: 32
Joined: Mon Jul 08, 2013 9:43 am
PostPosted: Tue Feb 04, 2014 11:18 am
I had a question. I'm on Section II: Data Entry, Step 3 and I'm a little lost on: List ( YourTable::Room ; YourTable::Teacher ; YourTable::Level )

I didn't see where to create those table in any other step. Am I creating new tables for those fields on the unused tab? I'm just a little confused.
SeedCode Staff
SeedCode Staff
Posts: 475
Joined: Wed Jan 02, 2013 11:47 am
PostPosted: Tue Feb 04, 2014 11:32 am
Hi Illyssa. That step is simply a way to accommodate multiple resource fields, if your solution happens to be set up that way. You basically use that List function to assemble the contents of your multiple fields into a single field, which is what this technique requires. You can skip that section if you're just working with a single "Resource" field (which is how the Calendar file ships).
Posts: 36
Joined: Tue Mar 31, 2009 2:14 am
Location: SINGAPORE
PostPosted: Mon Feb 24, 2014 9:15 pm
Thanks for the great mod.

My implementation is a bit more complicated. Using your example, sometime, I have to pick more than one teacher for the event. Yet, I want each teacher's name to show up in the column header when I view by teacher.

Can you advise how do I do that ?
SeedCode Staff
SeedCode Staff
Posts: 475
Joined: Wed Jan 02, 2013 11:47 am
PostPosted: Tue Feb 25, 2014 2:07 pm
You can choose multiple resources for an event by just formatting that field as check boxes. See the "Can I have multiple resources per event?" section at the bottom of this page:
http://www.seedcode.com/pmwiki/pmwiki.p ... .Resources
Posts: 4
Joined: Wed Jun 18, 2014 7:28 am
PostPosted: Wed Jun 18, 2014 9:42 am
So, I have worked through this tip, since I do have multiple resources, and my column headings in GRID view and row names in SCHEDULE view work perfectly. What doesn't work is the cells. I get my one scheduled resource under the GRID view and it doesn't appear at all on the SCHEDULE view.

I am sure that this is a user-problem, but have run out of things to test. It appears that my resource field on the layout Source No 1 is populated correctly. The scheduled item appears on the calendar layouts. The resource data is stored, though is obviously a multi-key as suggested by this post. I have included a screen shot so you can see what I see.

My forehead is a bit flattened from trying to figure this out, and I am hoping that you have seen this a "million" times before and will know the answer quickly.

Thanks!

*susan*

p.s. If I copy your layout from the original, untouched version, I also see my data hanging down below.
Attachments
Screen Shot 2014-06-18 at 1.34.02 PM.png
Screen Shot 2014-06-18 at 1.34.02 PM.png (127.32 KiB) Viewed 32963 times
SeedCode Staff
SeedCode Staff
Posts: 475
Joined: Wed Jan 02, 2013 11:47 am
PostPosted: Wed Jun 18, 2014 12:24 pm
Hi Susan. I'm not what's going on. You might try testing a copy of your file with simplified resource values (without the dashes, slashes, periods, etc.) I don't know that those things are problematic but I'd like to rule that out. Let me know how that goes.
Posts: 4
Joined: Wed Jun 18, 2014 7:28 am
PostPosted: Wed Jun 18, 2014 12:40 pm
I will test, but of course, this is the list of resources as given to me by the client so not sure what I would do if it is the hyphens or periods are the problem. Thanks!
Posts: 4
Joined: Wed Jun 18, 2014 7:28 am
PostPosted: Wed Jun 18, 2014 12:59 pm
No change in the behavior. I removed all the non-alphanumeric values, reran the Upon Opening script and confirmed that the new values were present.

I have attached a redo of the original screen shot, and one in layout mode to show that I don't have any fields trailing below.

*susan*
Attachments
Screen Shot 2014-06-18 at 4.56.26 PM.png
Screen Shot 2014-06-18 at 4.56.26 PM.png (127.11 KiB) Viewed 32958 times
Screen Shot 2014-06-18 at 4.56.04 PM.png
Screen Shot 2014-06-18 at 4.56.04 PM.png (123.24 KiB) Viewed 32958 times
SeedCode Staff
SeedCode Staff
Posts: 475
Joined: Wed Jan 02, 2013 11:47 am
PostPosted: Wed Jun 18, 2014 1:23 pm
Still not sure what's going on. It could be data-related. I'd be happy to help you troubleshoot if you don't mind sending your file with full-access login info to me at [email protected]
Posts: 4
Joined: Wed Jun 18, 2014 7:28 am
PostPosted: Thu Jun 19, 2014 11:50 am
Thanks Jeff for the offline help!

In case someone else ever sees this, check for trailing paragraph returns in your resource field.
SeedCode Staff
SeedCode Staff
Posts: 475
Joined: Wed Jan 02, 2013 11:47 am
PostPosted: Fri Jun 20, 2014 10:59 am
Correct - the culprit here was a trailing carriage return in the Resources field.

Return to SeedCode Calendar

Who is online

Users browsing this forum: No registered users and 3 guests

(855) SEEDCODE
[email protected]
Follow us: