You are viewing limited content. For full access, please sign in.

Question

Question

How to Extract Laserfiche Forms Monitor (Instances & Tasks) Data via SQL for Custom Dashboards?

asked on February 2

Hi, we are on Laserfiche 11 and want to build a custom consolidated dashboard/KPIs for a specific Laserfiche Forms process (for upper management). The built-in Forms dashboards are useful administratively, but we need to extract Monitor data via SQL so we can schedule/sync it into our own dashboard tables.

Is it possible to query the Forms database (directly or via supported reporting views) to retrieve the same fields shown in the Monitor → Instances and Monitor → Tasks grids for a specific process?

Instances fields needed (as per Monitor):

  • Instance, Status, Started by, Start date, Last updated, Current step, Current step start date, Current stage, Assigned to, End step, End date, Duration

Tasks fields needed (as per Monitor Tasks):

  • Task, Instance, Status, Assigned to, Task creation date, Due date, Priority, Action, Completion date, Completion performance, Duration, Last assigned date, Last updated date, Performance time, Task stage, Team

If yes, please share any sample SQL or the table/view names + joins required to extract these fields for a given process.

0 0

Replies

replied on February 4

I also wanted to mention for anyone following the thread that we’re actively exploring support for this capability in Laserfiche Cloud (direct access to Cloud platform data). It’s not available yet, but it is something our team is actively researching.

If this is a feature you’d find valuable, I’d love to hear more about your use cases. Your feedback can help influence how we design and prioritize the upcoming capability.

 

Andrew

2 0
replied on February 4

@████████ That is good to know as it is a key piece missing in cloud.  I reference the form DB tables for a lot of things because I don't have a clear view from any kind of built in dashboard.  I can send you a list of examples if that is helpful.

0 0
replied on February 4

That would be great, and thank you for the feedback!  My email is andrew.spear@laserfiche.com.

0 0
replied on February 2

Create a scheduled report of the data you need and have it save the excel/csv file to the repository. Either use workflow or have a custom script job somewhere grab the reports and push them to SQL.

0 0
replied on February 2

Thanks Zachary — appreciate the suggestion.

The export-to-Excel/CSV and to SQL part is already sorted on our side. The main challenge we’re facing is specifically around Tasks data. Laserfiche Forms currently allows scheduled reporting for Instances, but there is no equivalent scheduled reporting capability for Tasks, which prevents us from building a complete operational dashboard.

So while your approach works well for Instances, it doesn’t solve the Tasks visibility gap, which is critical for SLA, workload, and team performance KPIs.

If there is a supported way (or workaround) to extract Tasks-level data in a similar scheduled or automated way or SQL directly, that’s what we’re really trying to solve.

0 0
replied on February 2

Here is a script that should help you get the tasks assigned: 

SELECT      [Process Name], [Instance name], [Started by], [Last updated], [Assigned to], [Assigned to (username)], [Assigned to (email)], [Current step], [Step start date], [Start date], [Instance ID]
FROM            (SELECT        instance.bp_name AS [Process Name], instance.title AS [Instance name], 
                                                    CASE WHEN start_user_snapshot.displayname LIKE '%WORKFLOW%' THEN 'Workflow' ELSE start_user_snapshot.displayname END AS [Started by], instance.lastacted_date AS [Last updated], 
                                                    CASE WHEN bp_worker_resume.status = 5 THEN assigned_user_snapshot.displayname WHEN bp_worker_resume.status = 2 THEN assigned_user_snapshot.displayname WHEN assigned_user_team_snapshot.displayname
                                                     IS NULL THEN teams.name WHEN bp_worker_resume.status = 1 THEN assigned_user_team_snapshot.displayname END AS [Assigned to], 
                                                    CASE WHEN bp_worker_resume.status = 5 THEN assigned_user_snapshot.username WHEN bp_worker_resume.status = 2 THEN assigned_user_snapshot.username WHEN assigned_user_team_snapshot.displayname
                                                     IS NULL THEN team_users.username WHEN bp_worker_resume.status = 1 THEN assigned_user_team_snapshot.username END AS [Assigned to (username)], 
                                                    CASE WHEN bp_worker_resume.status = 5 THEN assigned_user_snapshot.email WHEN bp_worker_resume.status = 2 THEN assigned_user_snapshot.email WHEN assigned_user_team_snapshot.displayname IS NULL
                                                     THEN team_users.email WHEN bp_worker_resume.status = 1 THEN assigned_user_team_snapshot.email END AS [Assigned to (email)], bp_worker_resume.step_name AS [Current step], 
                                                    bp_worker_resume.assign_date AS [Step start date], instance.start_date AS [Start date], instance.bp_instance_id AS [Instance ID]
                          FROM            dbo.cf_bp_main_instances AS instance LEFT OUTER JOIN
                                                    dbo.cf_user_snapshot AS start_user_snapshot ON start_user_snapshot.id = instance.user_snapshot_id LEFT OUTER JOIN
                                                    dbo.cf_bp_worker_instances AS bp_worker ON bp_worker.bp_instance_id = instance.bp_instance_id LEFT OUTER JOIN
                                                    dbo.cf_bp_worker_instnc_to_resume AS bp_worker_resume ON bp_worker_resume.worker_instance_id = bp_worker.instance_id LEFT OUTER JOIN
                                                    dbo.cf_bp_worker_instance_history AS bp_worker_history ON bp_worker_history.instance_id = bp_worker.instance_id AND bp_worker_history.status = 'assigned' AND bp_worker_resume.owner_snapshot_id IS NULL
                                                     LEFT OUTER JOIN
                                                    dbo.cf_user_snapshot AS assigned_user_snapshot ON assigned_user_snapshot.id = bp_worker_resume.owner_snapshot_id LEFT OUTER JOIN
                                                    dbo.cf_user_snapshot AS assigned_user_team_snapshot ON assigned_user_team_snapshot.id = bp_worker_history.target_snapshot_id LEFT OUTER JOIN
                                                    dbo.teams AS teams ON teams.id = bp_worker_resume.team_id AND bp_worker_resume.owner_snapshot_id IS NULL LEFT OUTER JOIN
                                                    dbo.team_members AS team_members ON team_members.team_id = teams.id AND team_members.member_rights = 3 LEFT OUTER JOIN
                                                    dbo.cf_users AS team_users ON team_users.user_id = team_members.user_group_id
                          WHERE        (instance.status = 1) AND (bp_worker_resume.status = 5 OR
                                                    bp_worker_resume.status = 1 OR
                                                    bp_worker_resume.status = 2) AND (bp_worker_resume.assign_date IS NOT NULL)) AS subquery
GROUP BY [Process Name], [Instance name], [Started by], [Last updated], [Assigned to], [Assigned to (username)], [Assigned to (email)], [Current step], [Step start date], [Start date], [Instance ID]
ORDER BY [Start date]

 

0 0
replied on February 3

Thanks Angela for the tasks assigned SQL Query. Is it possible to include completed tasks in the same query or another query with additional columns (Task name, Due date, Last Assigned Date, Completion date, Action)?

 

This will help to calculate SLAs and performances in the dashboard.

0 0
replied on February 4

I will need some time to pick through the tables to see where each item is to add it.

0 0
replied on July 12

Hi Angela, any chance of getting the required fields in the query? Or if anyone can help, that will be appreciated. Thanks

0 0
replied on July 13

Sorry this one got away from me.  Pull each completed Task will produce a lot of rows so I went with the completed instance date but you can always tweak as you need.  I think this should get you what you are looking for: 

SELECT
    [Process Name], [Instance name], [Task], [Status], [Started by],
    [Assigned to], [Assigned to (username)], [Assigned to (email)],
    [Due date], [Last assigned date], [Completion date], [Action],
    [Start date], [Instance ID]
FROM (

    /* ---------- OPEN TASKS ---------- */
    SELECT
        instance.bp_name AS [Process Name],
        instance.title AS [Instance name],
        bp_worker_resume.step_name AS [Task],
        'Open' AS [Status],
        CASE WHEN start_user_snapshot.displayname LIKE '%WORKFLOW%' THEN 'Workflow' ELSE start_user_snapshot.displayname END AS [Started by],
        CASE WHEN bp_worker_resume.status IN (2,5) THEN assigned_user_snapshot.displayname
             WHEN assigned_user_team_snapshot.displayname IS NULL THEN teams.name
             WHEN bp_worker_resume.status = 1 THEN assigned_user_team_snapshot.displayname END AS [Assigned to],
        CASE WHEN bp_worker_resume.status IN (2,5) THEN assigned_user_snapshot.username
             WHEN assigned_user_team_snapshot.displayname IS NULL THEN team_users.username
             WHEN bp_worker_resume.status = 1 THEN assigned_user_team_snapshot.username END AS [Assigned to (username)],
        CASE WHEN bp_worker_resume.status IN (2,5) THEN assigned_user_snapshot.email
             WHEN assigned_user_team_snapshot.displayname IS NULL THEN team_users.email
             WHEN bp_worker_resume.status = 1 THEN assigned_user_team_snapshot.email END AS [Assigned to (email)],
        bp_worker_resume.due_date AS [Due date],
        bp_worker_resume.assign_date AS [Last assigned date],
        CAST(NULL AS datetime) AS [Completion date],
        CAST(NULL AS nvarchar(200)) AS [Action],
        instance.start_date AS [Start date],
        instance.bp_instance_id AS [Instance ID]
    FROM dbo.cf_bp_main_instances AS instance
    LEFT OUTER JOIN dbo.cf_user_snapshot AS start_user_snapshot ON start_user_snapshot.id = instance.user_snapshot_id
    LEFT OUTER JOIN dbo.cf_bp_worker_instances AS bp_worker ON bp_worker.bp_instance_id = instance.bp_instance_id
    LEFT OUTER JOIN dbo.cf_bp_worker_instnc_to_resume AS bp_worker_resume ON bp_worker_resume.worker_instance_id = bp_worker.instance_id
    LEFT OUTER JOIN dbo.cf_bp_worker_instance_history AS bp_worker_history ON bp_worker_history.instance_id = bp_worker.instance_id AND bp_worker_history.status = 'assigned' AND bp_worker_resume.owner_snapshot_id IS NULL
    LEFT OUTER JOIN dbo.cf_user_snapshot AS assigned_user_snapshot ON assigned_user_snapshot.id = bp_worker_resume.owner_snapshot_id
    LEFT OUTER JOIN dbo.cf_user_snapshot AS assigned_user_team_snapshot ON assigned_user_team_snapshot.id = bp_worker_history.target_snapshot_id
    LEFT OUTER JOIN dbo.teams AS teams ON teams.id = bp_worker_resume.team_id AND bp_worker_resume.owner_snapshot_id IS NULL
    LEFT OUTER JOIN dbo.team_members AS team_members ON team_members.team_id = teams.id AND team_members.member_rights = 3
    LEFT OUTER JOIN dbo.cf_users AS team_users ON team_users.user_id = team_members.user_group_id
    WHERE instance.status = 1
      AND bp_worker_resume.status IN (1,2,5)
      AND bp_worker_resume.assign_date IS NOT NULL

    UNION ALL

    /* ---------- LATEST COMPLETED TASK PER INSTANCE ---------- */
    SELECT
        [Process Name], [Instance name], [Task], [Status], [Started by],
        [Assigned to], [Assigned to (username)], [Assigned to (email)],
        [Due date], [Last assigned date], [Completion date], [Action],
        [Start date], [Instance ID]
    FROM (
        SELECT
            instance.bp_name AS [Process Name],
            instance.title AS [Instance name],
            archive.step_name AS [Task],
            'Completed' AS [Status],
            CASE WHEN start_user_snapshot.displayname LIKE '%WORKFLOW%' THEN 'Workflow' ELSE start_user_snapshot.displayname END AS [Started by],
            COALESCE(completed_by.displayname, completed_team.name) AS [Assigned to],
            completed_by.username AS [Assigned to (username)],
            completed_by.email AS [Assigned to (email)],
            history.due_date AS [Due date],
            history.start_date AS [Last assigned date],
            history.finish_date AS [Completion date],
            submission.action AS [Action],
            instance.start_date AS [Start date],
            instance.bp_instance_id AS [Instance ID],
            ROW_NUMBER() OVER (PARTITION BY instance.bp_instance_id ORDER BY history.finish_date DESC) AS rn
        FROM dbo.cf_bp_main_instances AS instance
        LEFT OUTER JOIN dbo.cf_user_snapshot AS start_user_snapshot ON start_user_snapshot.id = instance.user_snapshot_id
        INNER JOIN dbo.cf_bp_worker_instances AS bp_worker ON bp_worker.bp_instance_id = instance.bp_instance_id
        INNER JOIN dbo.cf_bp_worker_instance_history AS history ON history.instance_id = bp_worker.instance_id
        LEFT OUTER JOIN dbo.cf_bp_worker_instnc_to_resume_archive AS archive ON archive.id = history.archived_worker_instnc_to_resume
        LEFT OUTER JOIN dbo.cf_user_snapshot AS completed_by ON completed_by.id = COALESCE(history.owner_snapshot_id, history.target_snapshot_id)
        LEFT OUTER JOIN dbo.teams AS completed_team ON completed_team.id = history.team_id AND history.owner_snapshot_id IS NULL AND history.target_snapshot_id IS NULL
        LEFT OUTER JOIN dbo.cf_submissions AS submission ON submission.submission_id = history.submission_id
        WHERE history.status = 'complete'
    ) AS ranked
    WHERE rn = 1

) AS subquery
ORDER BY [Start date], [Instance ID], [Status]

 

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.