Schloss Schwanberg Part 8: Adding Guest Information

1 minute read time.

This is the eighth of a series of articles that will 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.

The previous article discussed displaying guest information.

This article will continue the case study and look at how to create the self service page that will allow a customer to add the details of new Guest

The starting point is the page "bookingdetail.asp".

The previous article showed how the simple 'Add Guest' link can be added as a hyperlink.

The hyperlink added calls the addguest.asp page.

There needs to be a screen block created under the Guest custom entity. I called this new List 'ssGuestEntry'.

Creating the Code for the Add Guest page.

The code for the addguest.asp can be separated out into addguestpagecode.js and an 'include' can link the code to the ASP page. This allows addguest.asp to be used to control the general style and layout of the page.

Below is the code contained in addguestpagecode.js.

[code language="javascript"]
<%
if (!CRM.Authenticated)
{
//Logon function defined in eWaress.js
//assumes ewarelogon.inc in folder
eWareLogin();
}
else
{
var intVisitorId = CRM.VisitorInfo("visi_personid");
var strKeyID= "oppo_opportunityid";
var Id = new String(Request.Querystring(strKeyID));
var intRecordId = 0;
if (Id.indexOf(",") > 0)
{
var Idarr = Id.split(",");
intRecordId = Idarr[0];
}
else if (Id != "")
{
intRecordId = Id;
}

//security check
var oppoRecord = CRM.FindRecord("Opportunity","oppo_opportunityid="+intRecordId + " and oppo_primarypersonid = "+intVisitorId );
if (oppoRecord.eof)
{
Response.Redirect("index.asp");
}
if (CRM.Mode==View)
{
CRM.Mode = Edit;
}
var myBlock = CRM.GetBlock("ssGuestEntry");
var myRecord = CRM.CreateRecord("Guest");
myRecord.gues_opportunityid= intRecordId;
myRecord.gues_personid= oppoRecord.oppo_primarypersonid;
Response.Write(myBlock.Execute(myRecord));
if (CRM.Mode ==Save)
{
Response.Redirect("bookingdetails.asp?oppo_opportunityid="+intRecordId);
}
}
%>
[/code]

Notes

  1. Opportunity ID (oppo_opportunityid) is passed as the unique ID of the booking record. This is then automatically added as a foreign key value to gues_opportunityid.
  2. Once the Guest record has been added the page is returned to the 'Manage Booking' (bookingdetails.asp) page.