Support Portal ContactGet in touch

Portal - Real-time Editing of CRM Records

   Words by CRM Consultancy

   on 30/08/2016 10:00:00

Cloudbridge offers a CRM Record Area Webcontrol that allows us to define a simple Form to show a Record from Dynamics CRM – and this provides traditional functionality to allow the User to edit the controls in the Form and click Save to passes these updates back to CRM.

However this process of Loading the Page and then Posting Back the User actions can (even with the addition of Update Panels and AJAX) be somewhat clunky – and often we may want a quicker more real-time process for taking updates from the User into CRM; particularly where we have a Checklist or other series of records that we want the User to edit, and not worry about clicking Save for each Row.

This article is aimed at showing how we can do this using the CRMCS Cloudbridge Tools.

clip_image001[4]

STEP 1 – Define the CRM Record Area

Add our CRMCS Record Area to the page and specify the content controls we want.

Mark-up

<crmcs:CRMRecordArea runat="server" ID="CaseForm2" FreeEdit="true"  EntityType="incident" ControlCssClass="form-control">

<div class="col-md-12 col-sm-12 col-xs-12">

    <div class="form-group">

        <label>Case Title</label>

        <crmcs:CRMTextbox ID="caseTitle" CRMField="title" Placeholder="Title of the Case" Width="98%" runat="server" />

    </div>

</div>

 

This gives the outline of the form – this should typically be done using the Bootstrap Framework for a good responsive design.

NOTE: For real-time edits that are not dependent on Postback, the FreeEdit=’true’ attribute is required as this initialises the CRM Record Area for Javascript/AJAX based updates.

 

STEP 2 – Handle the DataBind

Include the code-behind to initialise the CRMCS Record Area.

Code-behind

// load Form

CaseForm2.CRMId = _caseId.ToString();

CaseForm2.Service = Portalbaseline.UserContext.Instance.CrmService;

CaseForm2.DataBind();

 

This initialises the control, and retrieves back the relevant fields from CRM to display the Form.


STEP 3 – Add a Save Control

We then need to define a Save Control which will save and (optionally) show the current state to the User – the User will not need to click or interact with this control, but the logic will this control to be present to control the save logic. 

This needs to be defined within the body of the CRM Record Area:

Mark-up

<crmcs:CRMRecordAreaSave ID="saveButton" DebugMode="false" runat="server" />

 

The Debug tag here controlling whether we see an Alert Pop-up to confirm the save before the Update Message is passed to CRM.

The attributes for this control can also be used to control Data Validation on what updates should be blocked from being passed to CRM.

 

STEP 4 – Initialise our Client-side Scripting

We also need to ensure our Page or Master Page invokes the ‘CRMCSFreeSave.js’ script library from the Cloudbridge Framework:

Mark-up

<script src="/cloudbridge/js/CRMCSFreeEdit.js" type="text/javascript"></script>

 

As well as invoking an Init Script on the start-up of our page, this can either be done in the Mark-up for fixed pages, or defined in the Code-behind:

 

Mark-up

$(document).ready(function () {

  freeEditInit();

});

 

Code-Behind

ScriptManager.RegisterClientScriptBlock(base.Page, base.Page.GetType(), this.ID + "_initDataTables", "freeEditInit();”, true);

 

 

NOTE: When using Webforms, RegisterClientScriptBlock can be used when the Page is in the process of Posting Back, whereas RegisterStartupScript can be used on non-Postback Initial Page Load.

 

STEP 5 – Cover our Exits

The logic above will ensure that any changes will be saved a few seconds after being made, and a warning prompt will be shown if the user attempts to close the Browser window before any changes have been saved.

However if our page provides any other ways to navigate away from the page and so lose any unsaved changes (such as other Ajax or UpdatePanels) then our logic should ensure that any unchanged saves are saved back to CRM prior to the Page Change – to do this, we can include a simple Script Command that will handle any unsaved changes:

Mark-up

<crmcs:TabList ID="tabList" CssClass="sidebar-menu" SelectedClass="active" runat="server" ToUpdatePanelID="caseListUpdatePanel" ToPanelID="caseListPanel" RefreshScript="setForm(true, true, false);" LoseFocusScript="freeEditSaveAll();">

 

This script command will ensure that any changes are saved prior to Focus or the Page State moving elsewhere.

 

With all this in place, we can position our Form for direct Real-time/AJAX Edits from our Portal into CRM without Postback.

 

This can be very useful for building strong responsive User Interfaces, and doing so with a minimal amount of Code and Scripting outside of the common Cloudbridge Framework. 

 

In a future article we will look at how this logic can be taken into MVC over Webforms.

 

This approach mirrors the logic in Dynamics CRM (introduced with CRM 2015) of supporting automatic saving of changes without a visible SAVE button:

 

image

Share this Article

Search Articles

Filter Articles

CRM Tech DocMan

Recent Articles

CRMCS Quick Start Guide: How To Produce a Microsoft Teams Live Event Dynamics 365 Marketing: Lead Scoring and Sales Acceptance Designing and Developing Microsoft Power Apps Portals Thank You for Attending CRMCS’ Webinar - Achieving B2B sales excellence with Dynamics 365 & Microsoft Teams Thank You for Attending Our Webinar - Achieving B2B sales excellence with Dynamics 365 & Microsoft Teams Webinar: Discover How CRMCS Have United Dynamics 365, SharePoint and Microsoft Teams To Create Sales Excellence Ignite your workflow by adding DocDrive365 to Office 365 The CRMCS guide to everything you need to know about integrating Teams with Dynamics 365 Saving Time By Keeping Documents In One Place TDE Database Encryption with On Premise Dynamics The Key to Successful Compliance in 2020 Part 2: Let’s get GDPR Compliant with Microsoft Power Automate Top 3 Essential Tips for Remote Working Dynamics 365 Marketing: Top 5 Best Features Dynamics Day in the Life - Puma Investments Can you use Teams to amplify collaboration in Dynamics? Part 1: Using a Scheduled Power Automate to Trigger Expiry Date Reminders The secrets of successful document collaboration in Dynamics CRMCS launches new AppSource approved DocDrive365 Dynamics Day in the Life - Moneypenny Release Management Add the App to Dynamics DocDrive365 Security: Day One - Getting Started with Dynamics to SharePoint Permissions Building a New Scheduled Process using Flow
  • "Paul has made a real difference to how my team of 24 people record and store valuable customer data and sales opportunities. Highly recommended."

    James, Operations Director

  • "Understanding your business allows us to advise when to implement aspects of CRM and, likewise, when not to."

    Paul McQuillan, Managing Director

  • "Dynamics 365 and CRMCS have made a real lasting difference to our business, allowing us to replace older systems that were holding back our performance."

    Grahame, Chief Operating Officer

  • "James worked well with us to help connect CRM with Outlook and relate how this might benefit our team using CRM for Property Care."

    Natalie, Property Care Supervisor

  • "Matt was really good with helping us run User Testing on the new Compliance Module of our CRM System."

    Tom, Compliance Administrator

Prefer to go old-school?

Write to us using the below addresses.

Head Office
CRM Consultancy
61 Oxford Street
Manchester
M1 6EQ

London Office
CRM Consultancy London
Grosvenor Avenue
London

Content © CRM Consultancy.