Sample Implementation of a New Flash

Dovetail Agent includes two sample pages that show how to implement flash viewing. The samples are based on the Site Part and Site forms.

When the Site Part page is opened, the page attempts to find any flashes related to the site part. If it finds any, the flashes are displayed in the pop-up Flash List window, and a link is added to the Site Part form for future viewing. In both samples, the sample page can be easily compared to the baseline page to see how the modifications were applied.

Note: The example assumes that the Dovetail Admin Flash Tables page was used to create a flash-enabled object for the site_part table.

The sample code shown below is also included in sample/sample_site_part.asp. The code can be imported into the site_part.asp page if Flashes are set up for Site Parts. This functionality can be added to almost any page in Dovetail Agent.

Example: Adding a new flash

  1. Add this line in the include section at the top of the page:

    <!--#include file="../include/inc_flash.asp"-->
  2. Add this section after the primary query. It calls the API to retrieve the Flashes for the Contact:

    var boFlash = FCSession.CreateGeneric("alert_to_other");
    var boAlert = FCSession.CreateGeneric("alert");
    var alert_object = 45;
    var alert_count = get_flashes(boFlash, boAlert, alert_object, strObjid);

    // get flash style
    // to overide config_itm,
    // set flash_type = 0 for classic style
    // set flash_type = 1 for anywhere style
    var flash_type = FCSession.Item("config_itm.flash_style.i_value");
    if(flash_type == "" || !FCApp.is_it_a_field('alert','x_active')) flash_type = 0;

    // set flag for Flashes link
    var bFlashAnywhere = false;
    var bFlashClassic = false;
    if(FCApp.GetTableID('alert_table') > 0 && flash_type == 1) {
    var boFlash = FCSession.CreateGeneric('alert_table');
    boFlash.AppendFilter('table_or_view', '=', 'site_part');
    boFlash.Query();
    if(boFlash.Count() > 0) bFlashAnywhere = true;
    try{boFlash.CloseGeneric();}catch(e){}
    } else {
    bFlashClassic = true;
    }
    var flash_count = flash_count(strObjid, 15, "");
  3. Add this line to the HEAD portion of the site_part.asp page:

    <script language=javascript src="../flash/open_flash.js"></script>
  4. Add this function to the SCRIPT section of the page:

    function flash_pop(){
    if(<%=flash_count%> > 0) {
    OpenFlashAnywhereWindow(<%=strObjid%>, 15, '', <%=flash_type%>);
    }
    }

  5. Add the highlighted function call below to the onload routine of the <body> html tag:

    <body onload="AttachChangeEvent();ColorRequired();flash_pop();">
  6. Add this section to the BODY portion of the page in the menu area. This code adds the link to bring up the Flashes form shown below:

    <tr>
    <td height=30> </td>
    </tr>
    <tr>
    <% if(bFlashClassic || bFlashAnywhere) { %>
    <td align="center"><a id="flash" href="" onclick="OpenFlashAnywhereWindow(<% =boSitePart.id %>, 15, '', <% =flash_type %>);return false;">Flashes</a></td>
    <% } else { %>
    <td>&nbsp;</td>
    <% } %>
    </tr>
    <tr>
    <td>&nbsp;</td>
    </tr>

Example: Add the ability to view the Site Part Flash from a parent object's form

The sample code shown below is also included in sample/sample_site.asp. With these changes, the Flash List window will now list both the Site flashes and Site Part flashes.

  1. In baseline site.asp page, change this line:

    boFlash.Query();

    to this section:

    boFlash.BulkName = "flash";

    // Get the site_part records related to this site
    var boSitePart = FCSession.CreateGeneric('site_part');
    boSitePart.DataFields = 'objid';
    boSitePart.BulkName = "flash";
    boSitePart.TraverseFromRoot(boSite.id,'site','site2all_site_part');

    boFlash.Bulk.Query();

  2. Add this section:

    // add flash objects
    var strFlashArray = new Array();
    if(!bNew && bFlashAnywhere) {
    strFlashArray[strFlashArray.length] = "52|" + boSite.id;
    while(!boSitePart.EOF) {
    strFlashArray[strFlashArray.length] = "15|" + boSitePart.id;
    boSitePart.MoveNext();
    }
    }
    try {boSitePart.CloseGeneric();}catch(e){}

See Also

Flashes Anywhere

Setting Up Flashes Anywhere

Maintaining Flashes

Displaying Flashes

Converting Classic Flashes

Next

Graphical Reporting

Sample Implementation of a New Flash