יום חמישי, 6 במרץ 2014

Siebel Mobile Applications: Create Activities for Outbound Phone Calls

The following is a guest post by Sandra Wamsley, Programmer Analyst at Laerdal Medical. In her article she describes how to use a custom Physical Renderer in Siebel Mobile Applications to capture the event when the user taps the phone icon to make a call as an activity record in the Siebel database. The code samples and manifest configuration described are for Siebel 8.1.1.10 / 8.2.2.3.

***

When we first began developing our Mobile application, an early request came in for the application to automatically create an Activity when an outbound phone call was made through it.


 This was accomplished by having a physical renderer call a business service from within Siebel, which would create the activity. We had to accomplish this on two different business components - Accounts and Contacts - using two different fields.

The physical renderer had to accomplish three things: It had to see that the phone icon had been pressed in the application, get the Id of the Contact or Account that the icon had been pressed on, and invoke the business service, passing it the Contact or Account Id.

We created two physical renderers for our environment, because there were two business components that the business service could be invoked from - Accounts and Contacts. On the Account BC, the PR looks for “MainPhoneNumber” and on the Contact BC it looks for “WorkPhoneNum.”

Below is the code for the physical renderer:

if (typeof(SiebelAppFacade.MobileAccountFormAppletPR) === "undefined") {

 SiebelJS.Namespace("SiebelAppFacade.MobileAccountFormAppletPR");
 SiebelApp.S_App.RegisterConstructorAgainstKey ("MobileAccountFormAppletPR",  "SiebelAppFacade.MobileAccountFormAppletPR");

 SiebelAppFacade.MobileAccountFormAppletPR = (function () {

  function MobileAccountFormAppletPR(pm){
         SiebelAppFacade.MobileAccountFormAppletPR.superclass.constructor.call(this,pm);
 this.GetPM().AddMethod("ShowSelection",recordChanged,{sequence:false,scope:this})
 }

SiebelJS.Extend(MobileAccountFormAppletPR, SiebelAppFacade.JQMFormRenderer);

function recordChanged() {
  var that=this;
  $("#"+this.GetPM().Get("GetControls")["MainPhoneNumber"].GetInputName()+"_tel").on('click',function(){

  SiebelJS.Log(that.GetPM().Get("GetBusComp").GetFieldValue("Id"));

  var svc = SiebelApp.S_App.GetService("Create Activity");
  var iPS = SiebelApp.S_App.NewPropertySet();
  iPS.SetProperty("Account Id",that.GetPM().Get("GetBusComp").GetFieldValue("Id"));
  iPS.SetProperty("Contact Id", "");
  outPS = svc.InvokeMethod("CreateActivity", iPS).childArray[0];
  debugger;
  })
 }
 return MobileAccountFormAppletPR;
 }());
}

This PR was used for Accounts. When the phone icon is clicked to make an outgoing call, the PR gets the Business Component in use to pull the record’s Id (Contact or Account), gets the Business Service (Create Activity), and gives it the Account Id. It also sends a blank string for Contact Id, which we used as an indicator of which PR had been called, but there are many other ways to accomplish this.

The Contact PR was identical, except that it used “WorkPhoneNum” instead of “MainPhoneNumber”, and it sent the Contact Id and a blank string for Account Id.

In addition to the Physical Renderer, we needed to update our Custom Manifest and Manifest Extensions files. In the Custom Manifest XML file, the following two sections were added to the <PLATFORM Name=”Mobile”> section. “MobileAccountFormAppletPR” and “MobileContactFormAppletPR” were the names of the Physical Renderers created earlier.

<KEY Name="MobileAccountFormAppletPR">
<FILE_NAME> 3rdParty/jqmobile/mobiscroll-2.0.full.min.js      </FILE_NAME>
<FILE_NAME> 3rdParty/jqmobile/jquery.mobile.simpledialog.min.js  </FILE_NAME>
<FILE_NAME> siebel/jqmformrenderer.js                            </FILE_NAME>
<FILE_NAME> siebel/custom/MobileAccountFormAppletPR.js           </FILE_NAME>
</KEY>

<KEY Name="MobileContactFormAppletPR">
<FILE_NAME> 3rdParty/jqmobile/mobiscroll-2.0.full.min.js         </FILE_NAME>
<FILE_NAME> 3rdParty/jqmobile/jquery.mobile.simpledialog.min.js  </FILE_NAME>
<FILE_NAME> siebel/jqmformrenderer.js                            </FILE_NAME>
<FILE_NAME> siebel/custom/MobileContactFormAppletPR.js           </FILE_NAME>
</KEY>

In the Manifest Extensions file, we needed to specify which applets should load these PRs. We ended up with five applets that had the option of triggering a phone call, and set the correct PRs from there.

SHCE Account Entry Applet - Mobile = MobileAccountFormAppletPR
SHCE Account Entry Applet ReadOnly - Mobile = MobileAccountFormAppletPR
SHCE Sales Contact Form Applet - Mobile = MobileContactFormAppletPR
SHCE Sales Contact Form Applet ReadOnly - Mobile = MobileContactFormAppletPR
SHCE Contact Form Applet Mobile = MobileContactFormAppletPR

From the JavaScript side of things, that was everything that had to be done. We built a business service to actually create the activity, and once we got them communicating with each other, it worked as intended. Now the user can click the icon to make a phone call, and an activity will be automatically created for them.

***

Many thanks to Sandra for sharing

have a nice day

@lex

אין תגובות:

הוסף רשומת תגובה