#gpugsummit | #inreno15 #gpugsummit developing service applications with dexterity a no nonsense...
TRANSCRIPT
#GPUGSummit | #INreno15
#GPUGSummit
DEVELOPING SERVICE APPLICATIONS WITH DEXTERITY A NO NONSENSE STEP-BY-STEP GUIDE
David Musgrave MVPManaging Director,
Winthrop Development Consultants
Mariano Gomez MVPSenior Software Engineer,
Mekorma
#GPUGSummit | #INreno15 2
Introductions
Service Based Architecture
Microsoft Dexterity Service Patterns– Wrapped Windows– Decoupled Business Logic
Steps to Create Service Enabled Procedures
Q & A
AGENDA
#GPUGSummit | #INreno15 3
Managing Director of Winthrop Development Consultants
Microsoft Dynamics GP Most Valuable Professional (MVP)
Worked with Microsoft for 13 and a half years
Lives in Winthrop, a suburb in the city of Perth
Where is Perth, Western Australia?
DAVID MUSGRAVE
#GPUGSummit | #INreno15
Fun facts:Perth is the most isolated capital city in the world
Perth has the largest inner city park in the world, Kings Park, yes, bigger than even New York’s Central Park. It was also the first park to be designated for public use in Australia in 1872 and host to Australia's largest wild flower show and exhibition.Sharks
Dolphins
Sharks
Sharks with Lasers for EyesStinging
Jellyfish
Razor Sharp Coral
Cyclones
Stingrays
Sharks
Fires
Poisonous Snakes
Crocodiles
Giant Rats
Dingoes
Scorpions
Scorching Desert
Giant Spiders
Mosquitoes
Man-eating Koalas
Drop Bears
NOTHINGFloods
Tasmanian Devils
#GPUGSummit | #INreno15
© Kirk Hille – All rights reserved. Photograph used with express permission from Kirk Hille.
#GPUGSummit | #INreno15 6
Senior Software Engineer at Mekorma
Microsoft Dynamics GP Most Valuable Professional (MVP)
Lives in Atlanta, Georgia, USA
Born on a small Colombian island off the coast of Nicaragua
Where is San Andres Island?
MARIANO GOMEZ
#GPUGSummit | #INreno15
Fun facts:At only 39 square km, the island of San Andres is one of the smallest islands in the Caribbean Sea
It belongs to Colombia, but was a former British territory up to the early 1800s
#GPUGSummit | #INreno15
© Thierry Desgans – All rights reserved. Photograph used with express permission from Thierry Desgans.
#GPUGSummit | #INreno15 9
Introductions
Service Based Architecture
Creating Service Enabled Procedures– Wrapped Windows– Decoupled
Q & A
AGENDA
#GPUGSummit | #INreno15
Consumes and exposes servicesLogic in any dictionary including ISV products can be exposed as service operations.
Secure Access Use Windows or O365 Identity to authenticate.
https protocol with REST style API lets you build apps on many different platforms
Operation SecurityManaged within the application just like forms and reports.
Scalable Deploymentmodels fit any sized organization needs.
Discovery operations inform you of available operations and their syntax
Deployable on
Enhanced Interoperability gives developers additional capability to leverage the Microsoft Platform.
Integrate to other applications or services
#GPUGSummit | #INreno15
https://www.Contoso.com/GPService/
Endpoint
Apps and Devices
#GPUGSummit | #INreno15
PATTERN: [Context]/[Resource Path(keys)]?[Query String]
Hypothetical Examples GET …/Tenants(Default)/Companies(Contoso)/Sales/Customers(AARONFITZ0001)?format=summary POST …/Tenants(Default)/Companies(Contoso)/Sales/Customers DELETE …/Tenants(Default)/Companies(Fabrikam.%20Inc)/Manufacturing/Boms(WIDGET123) GET …/Tenants(Default)/Companies(Fabrikam.%20Inc)/Products(Id=346)/Boms?limit=20
THE ENDPOINT URI STRUCTURE
https://ip-gpweb.cloudapp.net/GPService/Tenants(Default)/Companies(Fabrikam, Inc.)/Dynamics/Inventory/Items(100XLG).xml
#GPUGSummit | #INreno15
Discover available operations on a live deployment—just add /Help
Use to model your code or extract info from system
Provides info on objects, parameter requirements
Discovery not filtered by security—you may see operations you can’t call
Example URI does not provide company context
DISCOVER YOUR URI
#GPUGSummit | #INreno15
WRAPPED WINDOW PATTERN
Validations Performed
Commit logic executed
ServiceCreateCustomer(customerObj)
Field Mapping
#GPUGSummit | #INreno15 18
DECOUPLED BUSINESS LOGIC PATTERN
Validations Moved
UI is reoriented to call validations
#GPUGSummit | #INreno15
STEPSCreate a business object classCreate a class for each object that you want to create
Add procedures to Microsoft Dexterity applicationAdd Get, GetList, Create, Update and Delete procedures for each objectYou may need to create multiples of these to handle different situationsYou may need to change your Dexterity application to handle errors
Create application DLLsCreate application and metadata DLLs using the DAG tool
Deploy and debugNOTE: Debugging using web services is not as simple as debugging a Dexterity applicationUpgrade for every new version of Dynamics GP
#GPUGSummit | #INreno15
WRAPPED WINDOWS
Create .NET object Included all fields from table Removed white spaces from names Created enumerations for radio groups and drop down lists
Preparation for window being wrapped Replace Warning_Dialogs Ask messages for actions need a predetermined action Ask messages and Add on the Fly Using TraceAdd and Trace
#GPUGSummit | #INreno15
REPLACING WARNING_DIALOGS{ Script: RM_Customer_Options Currency ID_CHG }'Company ID' of table MC_Currency_Access = 'Company ID' of globals;'Currency ID' of table MC_Currency_Access = 'Currency ID';get file MC_Currency_Access;
if err() = MISSING then {No access}if IsServiceMode() then
call TraceAdd of form Trace, field(GetTraceReference()), TRACE_FAILURE, 33002,
WARNING_MESSAGE, technicalname('Currency ID', QUALIFY_FULL), 'Company Name' of globals, 'Currency ID';
abort script;else
{Company %1 doesn't have access to currency %2.}call Warning_Dialog,33002,'Company Name' of globals,'Currency ID',"";restart field;abort script;
end if;end if;
#GPUGSummit | #INreno15
ASK MESSAGES WITH PREDETERMINED ACTION
{ Script: RM_Customer_Maintenance Delete_Button_CHG }
if IsServiceMode() thennAsk = ASKBUTTON1;
else{Are you sure you want to delete this customer record? Delete,
Cancel}nAsk = ask(getmsg(1349),getmsg(3),getmsg(1),"");
end if;
#GPUGSummit | #INreno15
ASK MESSAGES AND ADD ON THE FLY{ Script: RM_Customer_Maintenance Shipping_Method_CHG }
set 'Shipping Method' of file SY_Shipping_Methods_MSTR to 'Shipping Method';get file SY_Shipping_Methods_MSTR;
if err() <> OKAY thenif IsServiceMode() then
call TraceAdd of form Trace, field(GetTraceReference()), TRACE_FAILURE, 11585, GET_MESSAGE, technicalname('Shipping Method', QUALIFY_FULL);
elserestart field;set L_MSG to getmsg(2272);substitute L_MSG,'Shipping Method';if ask(L_MSG,getmsg(8),getmsg(1),"") = ASKBUTTON1 then
run script '(L) Shipping Profile Button';end if;
end if;end if;
#GPUGSummit | #INreno15
RETURN MESSAGES: FAILURE VS. WARNINGFailure is returned and Create/Update actions are not successful
if empty('Check Date') thenif IsServiceMode() then
call TraceAdd of form Trace, field(GetTraceReference()), TRACE_FAILURE, 2067, WARNING_MESSAGE, technicalname('Check Date', QUALIFY_FULL);
else{Please enter a date.}call Warning_Dialog, 2067,"","","";restart field;
end if;end if;
Warning is returned but Create/Update action is successful
if nError <> 0 thenif IsServiceMode() then
call TraceAdd of form Trace, field(GetTraceReference()), TRACE_WARNINGS, 15367, GET_MESSAGE, technicalname('Document Date', QUALIFY_FULL);
else{Fiscal period for this date does not exist. Continue, Cancel}if ask(getmsg(15367), getmsg(26), getmsg(1), "") = ASKBUTTON2 thenrestart field;abort script;end if;
end if;end if;
#GPUGSummit | #INreno15
ADDITIONAL TRACE LOGGINGTrace method available when warning or get messages are not applicable
catch [EXCEPTION_CLASS_FORM_FIELD_NOT_ACTIVE]{ no cleanup so just return errors } call Trace of form Trace, field(GetTraceReference()), TRACE_FAILURE,
technicalname(script CustomerMaintSetAccounts of form ServiceCustomer, QUALIFY_FULL),
substring(Exception_Message(), 1, 255);
else{ Trap the unexpected error that was found } call Trace of form Trace, field(GetTraceReference()), TRACE_FAILURE,
technicalname(script CustomerMaintSetAccounts of form ServiceCustomer, QUALIFY_FULL),
substring(Exception_Message(), 1, 255), ERROR_TYPE_INTERNAL;end try;
#GPUGSummit | #INreno15
SERVICE PROCEDURES
Code Samples and DemoCreate/Update Customer Address
Get Customer AddressDelete Customer Address
Inventory Transaction and Transfer
#GPUGSummit | #INreno15
DECOUPLED BUSINESS LOGIC
Business Logic is provided by source other than a UI form.– Ex. sproc, other web service, pass thru sql, “PD” forms in the
dictionary.• Ex of PD form. Form\IV_Item
Should be faster than wrapped window. Encourages separation of business logic and presentation.
Might require a refactor if business logic currently resides in a form.– How do decide whether to refactor?
• Frequency of use and throughput should drive the decision.
#GPUGSummit | #INreno15
DECOUPLED BUSINESS LOGIC
No implicit datatype validation/conversion.– Map statement in wrapped window takes care of casing, signed vs
unsigned precision and nulls.– In decoupled these things need to be coded.
• Examples for Decimals, Drop down lists and radio groups.
#GPUGSummit | #INreno15
DECOUPLED BUSINESS LOGIC
Check for valid sign and precision.
Check for valid value for a Drop Down or Radio Group.
#GPUGSummit | #INreno15
DECOUPLED BUSINESS LOGIC
Force strings to upper case as needed, for instance Item Number
Code must provide default values as needed in case the user passes a null value.
Demo create an Item.
#GPUGSummit | #INreno15 36
David Musgrave’s Winthrop Development Consultants Bloghttp://www.winthropdc.com/blog
The Microsoft Dynamics GP Blogster blog (by Mariano Gomez)http://dynamicsgpblogster.blogspot.com/
Developing for Microsoft Dynamics GP Blog – retired(by David Musgrave & the Developer Support Team)
http://blogs.msdn.com/DevelopingForDynamicsGP/ or http://aka.ms/Dev4DynGP
LINKS
#GPUGSummit | #INreno15
Click icon to add picture
CONTACT PRESENTERS
David [email protected]@winthropdc
Mariano [email protected] @dgpblogster