XWeb:IndividualFax HTML Form Enter ColdFusion Sample1
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 fax 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.cfx_unlisted_flag" default="">
<cfsavecontent variable="faxXML">
<cfoutput>
<ns:IndividualFaxObjects>
<ns:IndividualFaxObject>
<ns:cfx_cst_key>#form.cst_key#</ns:cfx_cst_key>
<ns:fax_number><cfif len(form.fax_number) neq 0>#trim(form.fax_number)#<cfelse></cfif></ns:fax_number>
<ns:cfx_extension><cfif len(form.cfx_extension) neq 0>#trim(form.cfx_extension)#<cfelse></cfif></ns:cfx_extension>
<ns:cfx_fxt_key>#form.cfx_fxt_key#</ns:cfx_fxt_key>
<ns:cfx_unlisted_flag>#val(form.cfx_unlisted_flag)#</ns:cfx_unlisted_flag>
<ns:cfx_add_user>#nfws_change_date#</ns:cfx_add_user>
<ns:cfx_add_date>#nfws_change_user#</ns:cfx_add_date>
</ns:IndividualFaxObject>
</ns:IndividualFaxObjects>
</cfoutput>
</cfsavecontent>
<cfinvoke component="/gateway/netforum_xweb" method="xweb_InsertFacadeObject" returnvariable="faxXML">
<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="IndividualFax" omit="no">
<cfinvokeargument name="oNode" value="#faxXML#" 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="qryGetFaxCategories" datasource="#nfdatabase#">
SELECT fxt_key,
fxt_code
FROM co_fax_type (nolock)
WHERE fxt_key NOT IN
(
SELECT cfx_fxt_key
FROM co_customer_x_fax
WHERE cfx_cst_key = '#session.cst_key#'
AND cfx_delete_flag = 0
)
AND fxt_delete_flag = 0
ORDER BY fxt_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">
Fax Number:<br />
<cfinput type="text" name="fax_number" value="" size="30" validate="telephone" required="yes" message="A fax number is required."><br />
</td><td valign="top">
Type:<br />
<cfselect name="cfx_fxt_key">
<option value="">-- select one --</option>
<cfloop query="qryGetFaxCategories">
<option value="#fxt_key#">#fxt_code#</option>
</cfloop>
</cfselect>
</td></tr>
<tr><td valign="top">
Extension:<br />
<cfinput type="text" name="cfx_extension" value="" size="5"><br />
</td><td valign="top">
Unlisted:<br />
<cfinput type="checkbox" name="cfx_unlisted_flag" value="1"><br />
</td><td valign="top">
<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>