Get Resources and Statuses from FileMaker

 Overview

By default, DayBack stores resources and statuses with its own settings. You can make new resources and statuses, make new folders, and change their sort order as shown here:

But you may already have FileMaker tables for your resources and statuses, so DayBack offers a way to pull these values in from FileMaker. You can pull all your values in from FileMaker or continue to have some resources and statuses stored in DayBack's settings. These scripts will let you base your filters and filter folders on your own FileMaker scripts, so you can do things like...

  • Load only the territories (resource folders) and direct reports (resources) for each sales manager as they log in;
  • Keep a complex list of equipment (resources) up to date in FileMaker instead of managing it by hand in DayBack;
  • User the same value list of project types (statuses) between DayBack and FileMaker.

Using FileMaker Tables for Resouces and/or Statuses

DayBack ships with two examples to show you how to do this. 

Status Example: Send JSON to DayBack

Take a look at the FileMaker script "Sample Statuses - DayBack" that comes with DayBack. This example builds a list of statuses, status colors, and folders in JSON. Use the JSON in this script as a guide for how you should format your own JSON; either hard-code it as we're doing or loop through your own records (or your own value list) to build a similar JSON object. 

If you need help writing a script that builds JSON like this, we can write that for you as part of an implementation package.

To run this example, you'll head to admin settings and create an app action with an "On Statuses Fetched" trigger like this:

Here's the code for that action:

var filterItems = [];
var item;
dbk.performFileMakerScript('Sample Statuses - DayBack', null, function(result) {
  	if (result && result.payload) {  	
      	for (var i = 0; i < result.payload.length; i++) {
          	item = result.payload[i];
          	dbk.mutateFilterField(item)
    		filterItems.push(item);
    	}
    }
    seedcodeCalendar.init('statuses', filterItems);
	actionCallbacks.confirm();
});

(This code uses the dbk.performFileMakerScript() function with lets you call any FileMaker script from within DayBack. It takes the script name as its first parameter, then any script parameters, then the name of any callback function you'd like to run.)

Note that this action is set to replace any statuses you have with the contents of the FileMaker script. That's done in the first line that initializes filterItems and in line 11, the seedcodeCalendar.init line. The Resources example below appends the contents of the FileMaker script to any resources already there and you can see those two lines are different.

To use the code above for resources, change two things: 

  1. the name of the FileMaker script in line 3. Remember that this script needs to produce JSON in the form used in "Sample Statuses - DayBack".
  2. replace "statuses" with "resources" in line 11.

Resources Example: Send a Simple List to DayBack

This example is very similar except that it just takes a list of resources as its starting point. This means you don't have to make any JSON on your end, but it also means that you can't create folders for your resources. You'd need to pass in a JSON object like that in the statuses example (and use the status-example style script) if you want to create folders automatically.

Take a look at the FileMaker script "Sample Resources - DayBack" that comes with DayBack. You'll see that in line 12 it just assembles a list of resource names. You could do this in a loop, using ListOf(), or using ValueListItems().

You'll run this script by creating an app action with an "On Resources Fetched" trigger like this:

Here's the code for that action:

var filterItems = seedcodeCalendar.get('resources');
var item;

dbk.performFileMakerScript('Sample Resources - DayBack', null, function(result) {
  	if (result && result.payload) {  	
      	for (var i = 0; i < result.payload.length; i++) {
          	item = dbk.nameToFilterItem(result.payload[i])
    		filterItems.push(item);
    	}
    }
	actionCallbacks.confirm();
});

Note since this action loads filterItems with the current content of 'resources', it appends the contents of the FileMaker script to any resources already in DayBack.

To use the code above for statuses, change two things: 

  1. the name of the FileMaker script in line 2. Remember that this script needs to produce a simple list of names in the form used in "Sample Resources - DayBack".
  2. replace "resources" with "statuses" in line 1.

Editing Resources and Statuses Created From Actions

Any filter items you create from actions like this are not stored in DayBack's settings and thus aren't editable in DayBack. You'll need to edit them, changing their color and sort order, in FileMaker in order to see changes in DayBack.


Locking Yourself Out with Custom Actions

If you write some really bad JavaScript, you can write an action that prevents DayBack from starting. You'll just see the blue loading bars run across the screen and you'll never get to the calendar. If that happens, close your FileMaker file (or navigate to another layout) and then return to DayBack while holding down the shift key and moving the mouse back and forth. That will cause DayBack to bypass any app-actions you've written and take you right to the settings screen where you can correct your action or turn it off.

(Turn your action "off" by unchecking the box next to "app" below the action.)

Still need help? Message Us Message Us