mirror of
https://github.com/SuiteCRM/SuiteCRM.git
synced 2026-03-02 19:16:58 -05:00
Provide Skeleton Logic Hook: Skeleton template to add sales pipeline date and duration tracking template #4540
Labels
No labels
Area: API
Area: Campaigns
Area: Cases
Area: Clean Up
Area: Clean Up: Performance
Area: Dashlets
Area: Databases
Area: Developer Tools
Area: Elasticsearch
Area: Elasticsearch
Area: Emails
Area: Emails:Campaigns
Area: Emails:Cases
Area: Emails:Compose
Area: Emails:Config
Area: Emails:Templates
Area: Environment
Area: Installation
Area: Language
Area: Mobile
Area: Module
Area: PDFs
Area: PHP8
Area: Reports
Area: Studio
Area: Styling
Area: Upgrading
Area: Workflow
Area:Activity Stream
Area:Calls
Area:Import
Area:Projects
Area:Search
Area:Surveys
Area:Themes
Area:Users
Branch:Hotfix
Good First Issue
Hacktoberfest
Help Wanted
PR:Community Contribution
PR:Type:Enhancement
Priority:Critical
Priority:Important
Priority:Moderate
Severity: Major
Severity: Minor
Severity: Moderate
Status: Requires Code Review
Status: Requires Updates
Status: Stale
Status: Team Investigating
Status:Assessed
Status:Fix Proposed
Status:Needs Assessed
Status:Requires Automated Tests
Type: Bug
Type:Deprecated
Type:Discussion
Type:Duplicate
Type:Invalid
Type:Question
Type:Suggestion
Type:Suggestion
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/SuiteCRM-SuiteCRM#4540
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @vmw on GitHub (May 21, 2021).
There are a number of uses for tracking the amount of time an opportunity spends in each sales stage. This information can be used in reports, or to determine sales cycle times and also useful conversion information. This seems to be a feature request that comes up a couple of times.
This pull request provides a (commented out) logic hook that can be easily modified to support this kind of reporting. It also provides a starting point for implementing custom logic.
https://community.suitecrm.com/t/sales-workflow/37301
Issue
There are two issues here; there isn't any skeleton or example code for how to implement a custom logic hook. And, there isn't an easy way to keep track of how the amount of time an opportunity spends in each sales stage.
This issue resolves both, by providing a commented example of a logic hook, which users can subsequently modify to meet their own needs.
Expected Behavior
Ideally, there should exist a sample template or dummy code that people can use when first learning about logic hooks. This would provide a better entry and allow people to test and develop their own logic hook implementations.
Actual Behavior
There aren't really any examples of functioning logic hooks.
Possible Fix
Submitting a PR that provides this example code, along with reasonably inline comments.
Context
We spent around 3 weeks trying to implement this feature for our own uses. During this time, we found that this was a reasonably common use case on the forums, but that concrete and detailed instructions for exactly how to implement a logic hook weren't readily available.
Instead, we had to piece it together from a number of different sources.
This commit, provides an example of a (commented out) functioning logic hook, albeit one that would need to be modified to support the default sales stages. It needs to be modified to support the default sales stages, and also requires some fields to be added, but otherwise works.
@gwendo12 commented on GitHub (May 21, 2021):
Purpose
To update sales stage duration in the pipeline.
Target Outcome
Files
Fields
Last Sales Stage
Display Label: Last Sales Stage
Field Type: DropDown
Field Name: time_in_discovery_c
Description: Need to create one property per sales cycle stage, like, "time_in_discovery_c" to keep track of the amount of time it has been in that property. If the sales stage is changed, then find the difference between when it was set (DateTime {StageName} Set), and when it was changed (DateTime Last Modified {StageName}), and keep track of that.
DateTime {StageName} Set
Display Label: DateTime Discovery Set
Field Type: DateTime
Field Name: last_sales_stage_c
Description: Create a DropDown field to keep track of the last sales stage the opp was in.
Date Sales Stage Set
Display Label: Date Sales Stage Set
Field Type: DateTime
Field Name: sales_stage_date_set_c
Description: Create a DateTime field to keep track of the last time the sales stage time information was set.
Time in {StageName}
Display Label: Time in Discovery
Field Type: Integer
Field Name: time_in_discovery_c
Description: Need to create one property per sales cycle stage, like, "time_in_discovery_c" to keep track of the amount of time it has been in that property. If the sales stage is changed, then find the difference between when it was set (DateTime {StageName} Set), and when it was changed (DateTime Last Modified {StageName}), and keep track of that.
Implementation Notes
Keepstrack, globally, of the last time you updated the duration an opportunity has been in any particular stage (last mod- on creation, last mod should equal current date time). The difference between the last time you updated any sales stage duration time, and the current time, corresponds to the duration that you need to add to the current sales stage (if the sale stage hasn’t changed), or to the last sales stage (if this is being triggered when changing sales stage).
Step 1: When was the last time we updated any sales stage duration for that opportunity?
Step 2: What is the current time?
=>This provides us with the duration that we need to account for. That’s because the whole point of this logic is to account for the how much time is spent (since the op was first created) in each sales stage.
Given that each opportunity is always in a particular stage, we can just find the difference between the last time we updated a duration, and the current time. That’s the amount of time that has elapsed since we last updated any record, and corresponds to the amount of time we should account for.
This is largely because the total time that this opportunity is open should correspond to the sum of durations that it is in each sales stage.