The Mobile CRM Conference 2015 September 14-15, 2015 in Boston, MA Take Your CRM to the Next Level.

51
The Mobile CRM Conference 2015 September 14-15, 2015 in Boston, MA Take Your CRM to the Next Level

Transcript of The Mobile CRM Conference 2015 September 14-15, 2015 in Boston, MA Take Your CRM to the Next Level.

Page 1: The Mobile CRM Conference 2015 September 14-15, 2015 in Boston, MA Take Your CRM to the Next Level.

The Mobile CRM Conference 2015September 14-15, 2015 in Boston, MA

Take Your CRM to the Next Level

Page 2: The Mobile CRM Conference 2015 September 14-15, 2015 in Boston, MA Take Your CRM to the Next Level.

A to Z of portable business logic

Technical Advanced Track

Juraj [email protected]

Page 3: The Mobile CRM Conference 2015 September 14-15, 2015 in Boston, MA Take Your CRM to the Next Level.

Business logic is the brain

Page 4: The Mobile CRM Conference 2015 September 14-15, 2015 in Boston, MA Take Your CRM to the Next Level.

Business logic

• Validate email address, postal code, telephone number

• Time duration is calculated (Actual End – Actual Start)

• A field is hidden / not editable based on a condition

• Populate fields on a child entity based on the parent

• Modify the Order Products to add a special discount• Find out how many appointments have been made

against an Account…

Page 5: The Mobile CRM Conference 2015 September 14-15, 2015 in Boston, MA Take Your CRM to the Next Level.

Dynamics CRM business logic

All business logic captured within• JavaScript• Workflows• UI scripts… has to be rewritten (recreated) for Mobile CRM

Data plugins will fire • Upon synchronization• Immediately in Online mode

Page 6: The Mobile CRM Conference 2015 September 14-15, 2015 in Boston, MA Take Your CRM to the Next Level.

Business logic in Resco Mobile CRM

Rules• Form• View• Calendar & Map

JavaScript• Form•HTML UI components

Page 7: The Mobile CRM Conference 2015 September 14-15, 2015 in Boston, MA Take Your CRM to the Next Level.

Rules

Mobile application scripts written directly in Woodford

Form • Events • Commands

ViewCalendarMap

Page 8: The Mobile CRM Conference 2015 September 14-15, 2015 in Boston, MA Take Your CRM to the Next Level.

Simple scripting language

Conditions (if …)Steps• Assignment• Get GPS Position• Say Text• …

Page 9: The Mobile CRM Conference 2015 September 14-15, 2015 in Boston, MA Take Your CRM to the Next Level.

Form Rules

Available on Edit FormExecuted on Form events / actions3 types• onLoad• onChange• onSave

Specialty –• onChange is executed during loading• Value is changing from nothing to something

Page 10: The Mobile CRM Conference 2015 September 14-15, 2015 in Boston, MA Take Your CRM to the Next Level.

onLoad

Triggered when the form is loaded (form is opened)

Typically:• Initialization of values• Initialization of the form

Specialty• isFormEditable – makes whole for not editable

Page 11: The Mobile CRM Conference 2015 September 14-15, 2015 in Boston, MA Take Your CRM to the Next Level.

onChange

Triggered when a field on the form has changed

Typically:• Validation checks• Setting of values• Items visibility

Specialty• ChangedItem – contains currently changed item• IsLoaded – if the form has finished loading

Page 12: The Mobile CRM Conference 2015 September 14-15, 2015 in Boston, MA Take Your CRM to the Next Level.

onSave

Triggered when the form is being saved

Typically:• Final check before saving

Specialty• ErrorMessage – prevents saving • WarningMessage – user decides whether to save or not

Note – setting values in Save is ignored

Page 13: The Mobile CRM Conference 2015 September 14-15, 2015 in Boston, MA Take Your CRM to the Next Level.

Form rules objects

• Entity – entity fields (data)• Form – items available on the detail tabs• Tabs – all the tabs• Variables – local variables• Shared variables – variables shared between the rules• Configuration – current user, URL, is online, …• Relationship – if form opened via associated view• Specialties

Page 14: The Mobile CRM Conference 2015 September 14-15, 2015 in Boston, MA Take Your CRM to the Next Level.

Use case – hide e-mail field

Account, Don’t Allow Emails field

If Don’t Allow Emails• Make Email field not available on the form

Page 15: The Mobile CRM Conference 2015 September 14-15, 2015 in Boston, MA Take Your CRM to the Next Level.

Use case – hide e-mail field

Page 16: The Mobile CRM Conference 2015 September 14-15, 2015 in Boston, MA Take Your CRM to the Next Level.

Use case – e-mail address validation

Email Address on the Contact form

Don’t allow saving a contact with incorrect email address• Inform the user with a message• Highlight the problematic field

Page 17: The Mobile CRM Conference 2015 September 14-15, 2015 in Boston, MA Take Your CRM to the Next Level.

Use case – e-mail address validation

Page 18: The Mobile CRM Conference 2015 September 14-15, 2015 in Boston, MA Take Your CRM to the Next Level.

Use case – field from parent entity

Contact has parent Account (parent company)Show Account’s website on the Contact formThe field should be not editable• Change is not reflected on the parent

Page 19: The Mobile CRM Conference 2015 September 14-15, 2015 in Boston, MA Take Your CRM to the Next Level.

Use case – field from parent entity

Page 20: The Mobile CRM Conference 2015 September 14-15, 2015 in Boston, MA Take Your CRM to the Next Level.

onChange – execution notes

Setting a value in the onChange ruletriggers the onChange rule again!

‘field = value’ will trigger onChange

Execution stops when the same value is being set• onChange isn’t called when new value is the same as

original value

Typical problem – DateTime.setNow

Page 21: The Mobile CRM Conference 2015 September 14-15, 2015 in Boston, MA Take Your CRM to the Next Level.

Form commands

Define commands (actions) for formCan use predefined• Change State & Status• Delete• Email link• Favorite• PrintReport• Scan (Contact, Lead)• Conversions

Or define own custom command

Page 22: The Mobile CRM Conference 2015 September 14-15, 2015 in Boston, MA Take Your CRM to the Next Level.

Form commands rules

On Execute• What should happen when a command is executed

On Can Execute• When a command should be available• Command.isEnabled

Script the same as on Form rulesBoth scripts can control standard & custom commands

Page 23: The Mobile CRM Conference 2015 September 14-15, 2015 in Boston, MA Take Your CRM to the Next Level.

Use case – load parent’s address

Contact – Parent Account

Custom command : Copy Address From Parent• Should copy Address fields• Available only if Address fields are empty

Page 24: The Mobile CRM Conference 2015 September 14-15, 2015 in Boston, MA Take Your CRM to the Next Level.

Use case – load parent’s address

Page 25: The Mobile CRM Conference 2015 September 14-15, 2015 in Boston, MA Take Your CRM to the Next Level.

Use case – only allow deleting of inactive recs.Contact Delete

Status Field (Active / Inactive)• Only show delete command if Contact is inactive

Page 26: The Mobile CRM Conference 2015 September 14-15, 2015 in Boston, MA Take Your CRM to the Next Level.

Use case – only allow deleting of inactive recs.

Page 27: The Mobile CRM Conference 2015 September 14-15, 2015 in Boston, MA Take Your CRM to the Next Level.

View rule

Similarly to Form rules there are also View rules

View rules can set• Row template• Variable – ‘virtual item’

Modifying entity properties won’t work!

Page 28: The Mobile CRM Conference 2015 September 14-15, 2015 in Boston, MA Take Your CRM to the Next Level.

Row templates

View - multiple row templates • Different rows (lines)

different look

Row script (view rule)• Which row template is used

TemplateIndex• Which template to use for

current line

Page 29: The Mobile CRM Conference 2015 September 14-15, 2015 in Boston, MA Take Your CRM to the Next Level.

Use case – highlighting big OpportunitiesOpportunity view

Different look for different Opportunities• Highlight the ones with revenue more than $100.000

Page 30: The Mobile CRM Conference 2015 September 14-15, 2015 in Boston, MA Take Your CRM to the Next Level.

Use case – highlighting big Opportunities

Page 31: The Mobile CRM Conference 2015 September 14-15, 2015 in Boston, MA Take Your CRM to the Next Level.

View rule on Map

Row definition contains Map pin• Flip view to map• Global Map

Map pin requires • Latitude & Longitude

View rule is respected on the map• Different pins for different

items

Page 32: The Mobile CRM Conference 2015 September 14-15, 2015 in Boston, MA Take Your CRM to the Next Level.

Use case – big Opportunities on Map

The same Opportunity view

Show Opportunities on a map based on their Account address• Different Pin different revenue

Page 33: The Mobile CRM Conference 2015 September 14-15, 2015 in Boston, MA Take Your CRM to the Next Level.

Use case – big Opportunities on Map

Page 34: The Mobile CRM Conference 2015 September 14-15, 2015 in Boston, MA Take Your CRM to the Next Level.

Calendar rule

Color of items (Color property)Possibility to reschedule by drag & drop (IsReadOnly)

Note!Entity object contains all the properties• If you want to use some – must be enabled in Select

Fields

Page 35: The Mobile CRM Conference 2015 September 14-15, 2015 in Boston, MA Take Your CRM to the Next Level.

Use case – Appointments with high priorityStandard Calendar• Appointments• Priority field

Show Calendar items in • Red if priority high• Green if normal• Blue = low

Page 36: The Mobile CRM Conference 2015 September 14-15, 2015 in Boston, MA Take Your CRM to the Next Level.

Use case – Appointments with high priority

Page 37: The Mobile CRM Conference 2015 September 14-15, 2015 in Boston, MA Take Your CRM to the Next Level.

Rules - summary

Form • Events

• onLoad• onChange• onSave

• Commands• onExecute• onCanExecute

View & MapCalendar

Page 38: The Mobile CRM Conference 2015 September 14-15, 2015 in Boston, MA Take Your CRM to the Next Level.

Rules – can do

• Access entity values • Access form / view / calendar properties• Load parent entity (via lookup)• Create variables & show them• Access GPS• Access configuration• Display a Message• …

Page 39: The Mobile CRM Conference 2015 September 14-15, 2015 in Boston, MA Take Your CRM to the Next Level.

Rules – can’t do

• Load children entities (for cycle)• Execute fetch (retrieve records)• Create, modify & save entities (except on form)

Page 40: The Mobile CRM Conference 2015 September 14-15, 2015 in Boston, MA Take Your CRM to the Next Level.

What if you need more?

Page 41: The Mobile CRM Conference 2015 September 14-15, 2015 in Boston, MA Take Your CRM to the Next Level.

Offline HTML & JavaScript Bridge

Page 42: The Mobile CRM Conference 2015 September 14-15, 2015 in Boston, MA Take Your CRM to the Next Level.

JavaScript Bridge can

• Load children entities (for cycle)• Execute fetch (retrieve records)• Create, modify & save entities• Access metadata• Create (local) files• …

Page 43: The Mobile CRM Conference 2015 September 14-15, 2015 in Boston, MA Take Your CRM to the Next Level.

What is Offline HTML?Flexible way to extend MobileCRM

Offline HTML• HTML pages (.html, .js, .css, .jpg, *)• Included into Mobile Project• Available offline for mobile app

Offline HTML is used for• Extending the Mobile CRM app UI• Adding business logic• Replacing the app’s UI completely

Page 44: The Mobile CRM Conference 2015 September 14-15, 2015 in Boston, MA Take Your CRM to the Next Level.

Offline HTML in Resco Mobile CRM

The HTML pages are displayed in a web browser window (IFrame)

Uses device’s browser• iOS – Safari• Android – Chrome• Windows – Internet Explorer

The IFrame can be placed on• Form (as tab)• Hidden – not visible• Containing only business logic

Page 45: The Mobile CRM Conference 2015 September 14-15, 2015 in Boston, MA Take Your CRM to the Next Level.

Resco JavaScript BridgeJSBridge.js - Component provided by RescoAllowing the HTMLs (JavaScript) to interact with Resco app

• Native UI• Data Layer (Fetch, Entities)• Other (Application, Configuration, Metadata, …)

You have to include it in your HTML / JS

Latest version available always here• http://www.resco.net/MobileCRM/downloads/JSBridge.js

Comprehensive reference of all functions & classes• http://www.resco.net/MobileCRM/support-jsbridge.aspx

Page 46: The Mobile CRM Conference 2015 September 14-15, 2015 in Boston, MA Take Your CRM to the Next Level.

Architecture

Offline HTML Pages

Resco JavaScript Bridge

Local DB…

& more

Page 47: The Mobile CRM Conference 2015 September 14-15, 2015 in Boston, MA Take Your CRM to the Next Level.

Business logic on Form with JSBridge

1. Create an HTML page with business logic in JavaScript2. Add that page as IFrame (tab) on a form3. Make the IFrame hidden

Work with:• onChange, onSave handler• onLoad – not present (body onload)• CreateCommand, onCommand, CommandEnabled

Page 48: The Mobile CRM Conference 2015 September 14-15, 2015 in Boston, MA Take Your CRM to the Next Level.

JSBridge – important classes

Dynamic Entity represents entity instance• createNew, load, save, properties[“fieldname”]

FetchXML for queries• construct, execute & process results

EntityForm for form interaction• onChange, onSave, form items, form properties, …

Page 49: The Mobile CRM Conference 2015 September 14-15, 2015 in Boston, MA Take Your CRM to the Next Level.

Rules vs. JavaScript? Which & when ?

Do you need to:• Load multiple records• Create, modify & save records• Perform computation on arbitrary number of fields• Process strings (extract part of a text field)

Go for JavaScript bridge

Everything else -> start with Rules

Page 50: The Mobile CRM Conference 2015 September 14-15, 2015 in Boston, MA Take Your CRM to the Next Level.

Shortcomings of JSBridge

Limited inter-form / multi-tab communicationNot available on views / listsNo global object

Asynchronous everywhere!

JavaScript Bridge objects different to Dynamics CRM

Page 51: The Mobile CRM Conference 2015 September 14-15, 2015 in Boston, MA Take Your CRM to the Next Level.

Thank you.

Help us improve!Rate this session in the resco.next app

TAKES

1 MINUTE