Schloss Schwanberg Part 3: Creating the Self Service ASP page to Capture the Lead

Hints, Tips and Tricks

Technical Hints Tips and Tricks that cover customization and development using Sage CRM. API usage and coding are covered.

Schloss Schwanberg Part 3: Creating the Self Service ASP page to Capture the Lead

  • Comments 8
  • Likes

This is the third of a series of articles that will walk you through the Schloss Schwanberg case study.

You can download the case study used at the conference here:

https://community.sagecrm.com/partner_community/m/example_training_case_studies_all_versions/default.aspx

You can read the all the existing articles that support the case study here: Schloss Schwanberg.

This article assumes that you have followed all the previous steps.

In the previous article we created the Lead screens needed to capture the details of the person making enquiry and the date and names of the people getting married.  We now need to create the self service page that will allow for the enquiry details to be captured into the database.

There is a page that we can use in the sample "Schloss Schwanberg" website we can use called enquiry.asp.

When we have finished the page we should be able to see it looking like the image below.

Coding the Page.

Self Service can work in one of two ways.  Either a page can allow a visitor to the corporate website to interact with the CRM data and meta data in an anonymous way or it can guard access and so require authentication.

The enquiry page needs to be able to allow visitors to be able to register an interest in booking the castle without needing to log on.  So the access to this page is going to be anonymous.

The general architecture of Self Service pages has been discussed in a series of previous articles.

You can use the Sage CRM SDK to install a series of useful snippets within Visual Studio.

The code for the Enquiry.asp has been seperated out into enquirypagecode.js and an 'include' links code to the page.  This allows enquiry.asp to be used to control the general style and layout of the page.

Below is the code contained in enquirypagecode.js

Note: One of the quirks of Self Service is that date fields are not rendered with the same controls that they are within the main interface.  This means that there is no date picker automatically included.  The code below uses a library from http://javascriptcalendar.org/

This creates a very helpful date picker.

[code language="javascript"]
<link rel="stylesheet" type="text/css" media="all" href="jsDatePick_ltr.min.css" />
<script type="text/javascript" src="jsDatePick.min.1.3.js"></script>
<script type="text/javascript">
    window.onload = function () {
        new JsDatePick({
            useMode: 2,
            target: "lead_weddingdate",
            dateFormat: "%d/%m/%y"
        });
    };
</script>
<%
Response.Expires = -1 
//get the screen for the lead
//create a record for the lead
//add the record to the screen and generate the HTML.
 
if (CRM.Mode == View)
{
CRM.Mode = Edit;
}
var MainContactTitleBox = CRM.GetBlock("content");
MainContactTitleBox.Title = "<span class=viewboxcaption>Your Details</span>";
var WeddingDetailTitleBox = CRM.GetBlock("content");
WeddingDetailTitleBox.Title = "<span class=viewboxcaption>The Couple's Details</span>";
 
var SSEnquiryMainContactBox = CRM.GetBlock("SSEnquiryMainContactBox");
var SSEnquiryWeddingDetailBox = CRM.GetBlock("SSEnquiryWeddingDetailBox");
SSEnquiryWeddingDetailBox.ShowValidationErrors = false;
//Set EntryBlock properties for an EntryGroup Block using an Enumerator
var myE = new Enumerator(SSEnquiryMainContactBox);
while (!myE.atEnd())
{
  myEntryBlock = myE.item();
  myEntryBlock.CaptionPos=3;
 
  myE.moveNext();
}
 
//Setup Block Container
var myBlockContainer = CRM.GetBlock("Container");
with (myBlockContainer)
{
  AddBlock(MainContactTitleBox);
  AddBlock(SSEnquiryMainContactBox);
  AddBlock(WeddingDetailTitleBox);
  AddBlock(SSEnquiryWeddingDetailBox);
}
 
var myRecord = CRM.CreateRecord("Lead");
var mydate = new Date();
myRecord.lead_opened = mydate.getVarDate();
myRecord.lead_source = "Web";
myRecord.lead_stage= "NewLead";
myRecord.lead_status= "In Progress";
myRecord.lead_createdby= 1;
myRecord.lead_channelid= 2;
myRecord.lead_assigneduserid= 18;
myRecord.lead_secterr = -1610612728;
myRecord.lead_description = Request.Form("lead_weddingdate")+" for "+Request.Form("lead_spouse1lastname")+" and "+Request.Form("lead_spouse2lastname");
myRecord.lead_details = "Booking Enquiry for "+ Request.Form("lead_weddingdate") + " wedding of " + Request.Form("lead_spouse1firstname")+" "+Request.Form("lead_spouse1lastname") + " and " +Request.Form("lead_spouse2firstname")+" "+Request.Form("lead_spouse2lastname");
myRecord.SetWorkflowInfo("Lead Workflow", "Assigned");
Response.Write(myBlockContainer.Execute(myRecord));
if (CRM.Mode == Save)
{
Response.Redirect("index.asp")
}
%>
[/code]

Note:  The code includes some setting of fields that are not included in the form interface.  This allows for the automatic population of fields such as lead_description, lead_details.  The lead is also allocated to a team, a territory, a user and placed into the workflow.

The new article will consider the workflow of the enquiry and the promotion to a booking or opportunity.

Comments
  • Hi Jeff,

    Enjoying this little exercise but.. I cannot get the datepicker working at all.

    Any hints please Jeff?

    Thank you.

    Regards,

    Penny Vaskess

    RDA Group

  • Penny

    I started by downloading the examples for the http://javascriptcalendar.org/ site and making sure that the simple example they provided worked.  Once I understood how the script referenced the field I was able to get it working on my site.  I had to make sure that the paths to the library files were correct.  So in the code below

    jsDatePick_ltr.min.css

    jsDatePick.min.1.3.js

    Are both included in the same folder as the ASP page.  I also made sure that I had the name of the field correct!  'lead_weddingdate'.

    <link rel="stylesheet" type="text/css" media="all" href="jsDatePick_ltr.min.css" />

    <script type="text/javascript" src="jsDatePick.min.1.3.js"></script>

    <script type="text/javascript">

    window.onload = function () {

    new JsDatePick({

    useMode: 2,

    target: "lead_weddingdate",

    dateFormat: "%d/%m/%y"

    });

    };

    </script>

  • Hi Jeff,

    All is as you suggested.. It may have to do with my version of IE (8) as the calendar appears not as a popup but as a vertical line with all the days (selectable) on the page itself.  I only just discovered it was loading something and the source view doesn't reveal anything obvious.

    Cheers Jeff.

  • Hi Jeff,

    Works perfectly in Chrome!

    Cheers,

    Penny

  • Hi Jeff

    Just a question about anonymous access. How the selfService knows the language to use for the traductions ? I've tried to set the language with visitorinfo language but there is no authenticated user so ..

    Have you got an idea ?

    Thanx alot !

  • Stanislas

    If the visitor is not authenticated then the Self Service site will not pick up the visitors language.  The self service captions will then display the captions in the system's default language.  This is set under

    Administration -> System -> System Behaviour

  • Hi Jeff  Is The training exercise still available for download ?

  • Gary

    Yes, I have recently double check the resources for the Schloss Schwanberg case study and everything is there.  I have made a note to write something up about this as the exercises are still very useful.  I think that you will need to check that you are logged on.  Some of the resources may only be available to members of the developer program. If you find dead links and believe you should be able to access the files then check with sagecrmteam@sage.com ..  If you still can get hold of the files then drop me a email and I should be able to sent them to you.