Skip to content

dirigiblelabs/sample-crm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sample - CRM

Eclipse License GitHub contributors Run on Dirigible

Overview

Sample CRM Application

Setup

Required environment/configuration variables:

Name Description Default Value
MAIL_USER The mailbox user -
MAIL_PASSWORD The mailbox password -
MAIL_RECIPIENT The mail recipient -
MAIL_PROTOCOL The mailbox protocol smtps
MAIL_HOST The mailbox host smtp.gmail.com
MAIL_PORT The mailbox port 465
MAIL_AUTH The mailbox auth true
  1. Setup Dirigible instance or use the trial one

  2. Clone the Sample CRM repository into your Dirigible instance:

    sample-crm-git-clone

  3. Setup a mail configuration:

    • Expand the crm-config project

    • Open mail.js

    • Replace the following snippet with your values:

      var mailUser = "<your-mail-user>";
      var mailPassword = "<your-mail-password>";
      var mailRecipient = "<the-mail-recipient>";

      sample-crm-mail-config

      TIP: Since Google’s Gmail SMTP server is being used, you’ll have to make some adjustment to your Google security settings. You’ll have to turn on the “Less secure app access” so that this e-mail can go through to your inbox:

      google_security_settings_border

      The first time, when mail is sent, a notification for "3rd party usage" in your Gmail mailbox will be sent, that needs to be confirmed.

Extend

  1. Extend the Entity Data Model (model.edm) file:

    • Switch to the Workbench perspective
    • Expand the crm project
    • Open the model.edm file
    • Drag & Drop new field to the Account entity
    • Rename the new field to HomePage
    • Right click on the HomePage field and click Properties
    • Go to the Data tab and change the Length property to 64
    • Go to the User Interface tab and set the Widget Type to URL and change the Length property to 64
    • Exit the Properties page
    • Save the model

    sample-crm-add-field

  2. Re-generate the application:

    • Right click on the model.model file
    • Click on the Generate option
    • Enter the following properties:
      • Extension: crm
      • Embedded: true
      • Title: CRM
      • Brand: CRM

    sample-crm-generate-application

  3. Add sample data:

    • Expand the crm project and select the index.html file
    • From the Preview view copy the application URL and open it in separate tab
    • Open the Account entity
    • Edit some of the account entries and enter the HomePage field

    sample-crm-add-home-page

BPM Process

  1. Overview:

    • Expand the crm-quote-approval and open the quote-approval.bpmn file
    • The process contains three steps and one flow condition:
      • StartProcessTask - initial task to set the execution context
      • SendNotificationTask - depending on the flow condition, the task is triggered when the Quote -> Amount is greaterr than 10 and mail notification is sent
      • AutoApproveTask - auto approval of the created Quote if the Amount is less than 10

    sample-crm-process-overview

  2. Trigger the Quote Approval process:

    • Navigate to the Sales section and select the Quote tile
    • Select the Quote tab, if needed
    • Create new Quote with Ammount greater than 10

    sample-crm-create-quote

    After few seconds, "Quote Approval" mail should be recieved:

    mail-recieved

  3. Update the mail message template:

    • Expand the crm-quote-approval project and open the mail.html file
    • Replace the file content with this one:
        <!DOCTYPE html>
    
        <head>
        </head>
    
        <body>
            <h1>[Approve Quote] ${quoteAccount} - ${quoteProduct}</h1>
            <hr>
            <p>
                <b>Account</b>: <i>${quoteAccount}</i>
            </p>
            <p>
                <b>Product</b>: <i>${quoteProduct}</i>
            </p>
            <p>
                <b>Discount</b>: <i>${quoteDiscount}</i>
            </p>
            <p>
                <b>Quote Amount</b>: <i>${approveAmount}</i>
            </p>
            <br>
            <a href="https://www.dirigible.io">Approve</a>
        </body>
    
        </html>
    • Create new Quote with Amount less than 10 to trigger the notification process with the updated mail template
  4. Update process:

    • Other changes to quote-approval.bpm can be made, such as:
      • Update the flow condition (e.g. change it to greater than 100)
      • Add new step(s)
      • Add new flow condition(s)
    • To apply the updated process follow these steps:
      • Click on the Save icon
      • Right click on the crm-quote-approval project and select Publish from the menu
      • Wait around 30 sec. before triggering the updated process
    • Open the Create Quote listener:
      • open the quote-create.listener file
      • when crm/Sales/Quote/Create event is created, then the crm-quote-approval/triggerApprovalProcess.js handler will be triggered
      • open the triggerApprovalProcess.js file to see how the quote-approval process is being started

Tips & Tricks

In some cases, when updating the Entity Domain Model (model.edm), incompatible changes may occur. To resolve these issues, here are some Tips & Tricks about it:

  1. Delete the generated files:
    • Delete all files under the "crm" project except model.edm, model.model and project.json
  2. Unpublish the crm project
  3. Re-generated the application from the updated model.model
  4. Publish the crm project

sample-crm-tips-and-tricks-1

In most cases, the previous steps should be enough to resolve issues from an incompatible change in the model. However, if incompatible change in the Data layer is made (e.g. Null -> Not Null, VARCHAR -> INTEGER, ...) then one addition step should be executed first:

  1. Go to the Database perspective
  2. Find the database table(s), to which incompatible changes were made
  3. Right click on it
  4. Select Drop Table from the menu

Otherwise execute SQL queries, to drop the table(s), from the SQL view:

drop table STUDENTS

sample-crm-tips-and-tricks-2

In some cases the generated application view(s) may disappear or be closed by accident. To reset the default layout follow these steps:

  1. Click on the "Themese" menu
  2. Select the "Reset" option

sample-crm-tips-and-tricks-3

License

This project is copyrighted by SAP SE and is available under the Eclipse Public License v 2.0. See LICENSE and NOTICE.txt for further details.