XWeb: IndividualPhone HTML Form Enter ColdFusion Sample 1

ColdFusion makes it very easy to integrate with web services. One of the most common requirements an organization has is the need to insert and update a variety of member information. Most often, this includes individual's addresses, phone numbers, fax numbers, and e-mail addresses.

The code provided below is an example of how HTML, ColdFusion, and xWeb can be used to Enter an individual's phone number.

Assumptions

In order to use the code provided below, you will need to have successfully implemented the various web methods using the required core ColdFusion component for xWeb.

Sample Code

<!--- Process Update --->
<cfif ISDEFINED("btn_enter")>
<cfparam name="form.cph_unlisted_flag" default="">
<cfsavecontent variable="phnXML">
<cfoutput>
<ns:IndividualPhoneObjects>
<ns:IndividualPhoneObject>
<ns:cph_cst_key>#form.cst_key#</ns:cph_cst_key>
<ns:phn_number><cfif len(form.phn_number) neq 0>#trim(form.phn_number)#<cfelse></cfif></ns:phn_number>
<ns:cph_extension><cfif len(form.cph_extension) neq 0>#trim(form.cph_extension)#<cfelse></cfif></ns:cph_extension>
<ns:cph_pht_key>#form.cph_pht_key#</ns:cph_pht_key>
<ns:cph_unlisted_flag>#val(form.cph_unlisted_flag)#</ns:cph_unlisted_flag>
<ns:cph_add_user>#nfws_change_date#</ns:cph_add_user>
<ns:cph_add_date>#nfws_change_user#</ns:cph_add_date>
</ns:IndividualPhoneObject>
</ns:IndividualPhoneObjects>
</cfoutput>
</cfsavecontent>
<cfinvoke component="/gateway/netforum_xweb" method="xweb_InsertFacadeObject" returnvariable="phnXML">
<cfinvokeargument name="nfws_namespace" value="#application.nfws_namespace#" omit="no">
<cfinvokeargument name="nfws_address" value="#application.nfws_address#" omit="no">
<cfinvokeargument name="nfws_token" value="#session.nfws_token#" omit="no">
<cfinvokeargument name="szObjectName" value="IndividualPhone" omit="no">
<cfinvokeargument name="oNode" value="#phnXML#" omit="no">
</cfinvoke>
<script language="javascript" type="text/javascript">
alert('Request Completed.\nClick OK to continue.');
var oParent = window.opener;
oParent.location.reload();
window.close();
</script>
<cfabort>
</cfif>
 
<!--- xweb_Authenticate : Initialize --->
<cftry>
<cfinvoke component="/gateway/netforum_xweb" method="xweb_Authenticate" returnvariable="nfws_token">
<cfinvokeargument name="uname" value="#application.nfws_uname#" omit="no">
<cfinvokeargument name="pword" value="#application.nfws_pword#" omit="no">
</cfinvoke>
<!--- xweb_GetFacadeObject : Customer --->
<cfinvoke component="/gateway/netforum_xweb" method="xweb_GetFacadeObject" returnvariable="qryCustomerPrimary">
<cfinvokeargument name="nfws_namespace" value="#application.nfws_namespace#" omit="no">
<cfinvokeargument name="nfws_address" value="#application.nfws_address#" omit="no">
<cfinvokeargument name="nfws_token" value="#session.nfws_token#" omit="no">
<cfinvokeargument name="szObjectName" value="Customer" omit="no">
<cfinvokeargument name="szObjectKey" value="#session.cst_key#" omit="no">
</cfinvoke>
<cfquery name="qryGetPhoneCategories" datasource="#nfdatabase#">
SELECT pht_key,
pht_code
FROM co_phone_type (nolock)
WHERE pht_key NOT IN
(
SELECT cph_pht_key
FROM co_customer_x_phone
WHERE cph_cst_key = '#session.cst_key#'
AND cph_delete_flag = 0
)
AND pht_delete_flag = 0
ORDER BY pht_code
</cfquery>
<cfcatch type="any">
<h4>Unable to connect to the web service gateway.</h4>
<cfflush>
<cfabort>
</cfcatch>
</cftry>
 
<!--- Display Form --->
<div style="width:600px; background-color:white;">
<br />
<cfform action="#cgi.script_name#" method="post" id="upd">
<cfoutput query="qryCustomerPrimary">
<strong>#cst_name_cp#</strong>:<br />
<br />
<table>
<tr><td valign="top" colspan="2">
Phone Number:<br />
<cfinput type="text" name="phn_number" value="" size="30" validate="telephone" required="yes" message="A phone number is required."><br />
</td><td valign="top">
Type:<br />
<cfselect name="cph_pht_key">
<option value="">-- select one --</option>
<cfloop query="qryGetPhoneCategories">
<option value="#pht_key#">#pht_code#</option>
</cfloop>
</cfselect>
</td></tr>
<tr><td valign="top">
Extension:<br />
<cfinput type="text" name="cph_extension" value="" size="5"><br />
</td><td valign="top">
Unlisted:<br />
<cfinput type="checkbox" name="cph_unlisted_flag" value="1"><br />
</td><td valign="top">
&nbsp;<br />
</td></tr>
</table>
 
<br />
 
<table width="100%">
<tr><td colspan="3" align="right">
<cfinput type="hidden" name="cst_key" value="#trim(cst_key)#" />
<cfinput type="submit" name="btn_enter" value="ENTER" />
<cfinput type="reset" name="btn_reset" value="RESET" />
<cfinput type="button" name="btn_close" value="CLOSE" onclick="var oParent = window.opener; oParent.location.reload(); window.close();" />
</td></tr>
</table>
</cfoutput>
<br />
</cfform>
</div>