GithubHelp home page GithubHelp logo

kakarlajoseph-outlook / routeplanner-sfx Goto Github PK

View Code? Open in Web Editor NEW

This project forked from heroku-examples/routeplanner-sfx

0.0 0.0 0.0 678 KB

Traveling Salesperson Problem with Salesforce Functions

HTML 6.02% JavaScript 16.09% Java 65.86% ObjectScript 12.03%

routeplanner-sfx's Introduction

Route Planner Demo

Node.js + Platform Events

This demo uses a combination of Flow, Salesforce Functions, CDC, and Lightning Web Components.

Demo flow:

  • Open account record
  • Click Quick Action "New Delivery"
  • Enter data in Flow, which will create a Platform Event
  • Wait for "Current Deliveries" to update (CDC listens in LWC)

Salesforce org setup

This demo uses Salesforce Functions local development environment integrated with a scratch org, you can use a Developer Edition Org.

  1. Create a scratch org.
sfdx force:org:create -s -f config/project-scratch-def.json -a routeplannerdemo
  1. Push source to scratch org.
sfdx force:source:push
  1. Assign permissionset
sfdx force:user:permset:assign -n RoutePlanner
  1. Import sample data
sfdx force:data:tree:import -p data/Account-Service__c-plan.json
  1. Open the org
sfdx force:org:open
  1. In Setup go to Data -> Data Integration Rules, and activate Geocodes for Account Shipping Address.

Functions setup

As the DX is in flux this section only describes the minimum needed information.

  • The function for this demo is located in functions/routeplanner.
  • The permissionset to use is RoutePlanner - for function assignment and for the Platform Event assignment.

Route Planner Function

diagram

Once you complete the steps below to setup and run the Function you should see these records. DELIVERYROUTE__R.NAME shows the route the vehicle should take and NUMBER__C represents the waypoints on that route to each service location in the most optimal order.

DELIVERYPLAN__C                          DELIVERYROUTE__R.NAME  VEHICLENAME__C  NUMBER__C  SERVICE__R.NAME
───────────────────────────────────────  ─────────────────────  ──────────────  ─────────  ────────────────────────────
Delivery Plan @ 2019-02-09 15:43:09.845  R-00000000             Van             1          Delivery to Beniof Mansion
Delivery Plan @ 2019-02-09 15:43:09.845  R-00000000             Van             3          Delivery to Landmark
Delivery Plan @ 2019-02-09 15:43:09.845  R-00000001             Van             2          Delivery to Salesforce Tower
Delivery Plan @ 2019-02-09 15:43:09.845  R-00000001             Van             4          Delivery to Salesforce West

Local Development

On a terminal run the following:

cd functions/routeplanner
sf run function start

On another terminal run the following:

cd functions/routeplanner
sf run function -l http://localhost:8080 -p=@data/sample-payload.json

routeplanner-sfx's People

Contributors

julianduque avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.