ColdFusion Fax - Query Submitted Faxes with FaxQuery2

This sample demonstrates how to retrieve detailed information about submitted faxes from ColdFusion. This is done using the FaxQuery2 method, which has more flexible querying options than FaxQuery (for more details, see Side-by-side Comparison of Web Service Methods).

The following ColdFusion fax snippet displays information about a number of submitted faxes. The options below allow flexible querying, and enable you to control how the list is displayed:


<cfoutput>

<!--- Username and password for the Interfax account. --->
<cfset interfaxUsername = "">
<cfset interfaxPassword = "">

<!---
    Settings begin
    See http://www.interfax.net/en/dev/webservice/reference/faxquery2
    for an explanation of properties

    Valid values for [property]_verb are:
    Equals | GreaterThan | GreaterOrEqual | LessThan | LessOrEqual | Like | IncludedIn | Between
    Leave both [property]_verb and [property]_data empty to ignore the property in the query
 --->
<!--- The values in this structure define the returned population --->
<cfset queryForm = StructNew()>

<!--- The values in this structure define how the population is returned --->
<cfset queryControl = StructNew()>

<cfset queryForm.Subject.Verb = "">
<cfset queryForm.Subject.VerbData = "">

<cfset queryForm.FaxNumber.Verb = "">
<cfset queryForm.FaxNumber.VerbData = "">

<cfset queryForm.DateFrom = "">
<cfset queryForm.DateTo = "">

<cfset queryForm.UserID.Verb = "">
<cfset queryForm.UserID.VerbData = "">

<cfset queryForm.ReplyAddress.Verb = "">
<cfset queryForm.ReplyAddress.VerbData = "">

<cfset queryForm.TransactionID.Verb = "">
<cfset queryForm.TransactionID.VerbData = "">

<cfset queryForm.ParentTransactionID.Verb = "">
<cfset queryForm.ParentTransactionID.VerbData = "">

<cfset queryForm.Status.Verb = "">
<cfset queryForm.Status.VerbData = "">

<!--- The following values control display settings --->
<cfset queryForm.ShowHiddenTransactions = true>
<cfset queryControl.OnlyParents = false>
<cfset queryControl.NumOfResults = 999>
<cfset queryControl.StartingRecord = 0>

<!---
    Valid values for $order_by are:
    TransactionID | SubmitTime | CompletionTime | Status | DestinationFax | Subject | PagesSent | UserID | ReplyEmail
--->
<cfset queryControl.OrderBy = "TransactionID">
<cfset queryControl.AscOrderDirection = true>
<cfset queryControl.ReturnItems = true>
<cfset queryControl.ReturnStats = true>

<!--- Settings end --->


<!--- Set default values for empty query properties --->

<cfif Not (Len(Trim( queryForm.Subject.Verb )) and Len(Trim( queryForm.Subject.VerbData )))>
    <cfset queryForm.Subject.Verb = "Equals">
    <cfset queryForm.Subject.VerbData = "">
</cfif>

 <cfif Not (Len(Trim( queryForm.FaxNumber.Verb )) and Len(Trim( queryForm.FaxNumber.VerbData )))>
    <cfset queryForm.FaxNumber.Verb = "Equals">
    <cfset queryForm.FaxNumber.VerbData = "">
</cfif>

<cfif Not (Len(Trim( queryForm.DateFrom )))>
    <cfset queryForm.DateFrom = CreateDateTime("1999", "01", "01", "00", "00", "01")>
</cfif>

<cfif Not (Len(Trim( queryForm.DateTo )))>
    <cfset queryForm.DateTo = CreateDateTime("2999", "12", "31", "23", "59", "59")>
</cfif>

<cfif Not (Len(Trim( queryForm.UserID.Verb )) and Len(Trim( queryForm.UserID.VerbData )))>
    <cfset queryForm.UserID.Verb = "Equals">
    <cfset queryForm.UserID.VerbData = "">
</cfif>

<cfif Not (Len(Trim( queryForm.ReplyAddress.Verb )) and Len(Trim( queryForm.ReplyAddress.VerbData )))>
    <cfset queryForm.ReplyAddress.Verb = "Equals">
    <cfset queryForm.ReplyAddress.VerbData = "">
</cfif>

<cfif Not (Len(Trim( queryForm.TransactionID.Verb )) and Len(Trim( queryForm.TransactionID.VerbData )))>
    <cfset queryForm.TransactionID.Verb = "Equals">
    <cfset queryForm.TransactionID.VerbData = "">
</cfif>

<cfif Not (Len(Trim( queryForm.ParentTransactionID.Verb )) and Len(Trim( queryForm.ParentTransactionID.VerbData )))>
    <cfset queryForm.ParentTransactionID.Verb = "Equals">
    <cfset queryForm.ParentTransactionID.VerbData = "">
</cfif>

<cfif Not (Len(Trim( queryForm.Status.Verb )) and Len(Trim( queryForm.Status.VerbData )))>
    <cfset queryForm.Status.Verb = "Equals">
    <cfset queryForm.Status.VerbData = "">
</cfif>
<!--- End setting default values --->


<!--- Create and call the web service --->
<cfset faxWebService = CreateObject("webservice", "https://ws.interfax.net/dfs.asmx?WSDL")>

<cfset faxItems = faxWebService.FaxQuery2(interfaxUsername, interfaxPassword, queryForm, queryControl)>


<!--- If call was succesfull then display fax items--->
<cfif faxItems.getResultCode() eq 0>

        <h1>Stats</h1>
        <cfloop from="0" to="#ArrayLen( faxItems.getStats().getStatusCount() ) - 1#" index="statsIndex">
            <table border="2">
                <tr><th>Status</th><td>#faxItems.getStats().getStatusCount( JavaCast("int", statsIndex) ).getStatus()#</td></tr>
                <tr><th>Count</th><td>#faxItems.getStats().getStatusCount( JavaCast("int", statsIndex) ).getCount()#</td></tr>
            </table>
            <br />
        </cfloop>

        <h1>Details</h1>
        <cfloop from="0" to="#ArrayLen( faxItems.getFaxItems().getFaxItemEx2() ) - 1#" index="faxIndex">
            <cfset currentFaxItem = faxItems.getFaxItems().getFaxItemEx2( JavaCast("int", faxIndex) )>

            <table border="2">
                <tr><th>ParentTransactionID</th><td>#currentFaxItem.getParentTransactionID()#</td></tr>
                <tr><th>TransactionID</th><td>#currentFaxItem.getTransactionID()#</td></tr>
                <tr><th>SubmitTime</th><td>#currentFaxItem.getSubmitTime()#</td></tr>
                <tr><th>PostponeTime</th><td>#currentFaxItem.getPostponeTime()#</td></tr>
                <tr><th>CompletionTime</th><td>#currentFaxItem.getCompletionTime()#</td></tr>
                <tr><th>UserID</th><td>#currentFaxItem.getUserID()#</td></tr>
                <tr><th>Contact</th><td>#currentFaxItem.getContact()#</td></tr>
                <tr><th>Job</th><td>#currentFaxItem.getJobID()#</td></tr>
                <tr><th>DestinationFax</th><td>#currentFaxItem.getDestinationFax()#</td></tr>
                <tr><th>ReplyEmail</th><td>#currentFaxItem.getReplyEmail()#</td></tr>
                <tr><th>RemoteCSID</th><td>#currentFaxItem.getRemoteCSID()#</td></tr>
                <tr><th>PagesSent</th><td>#currentFaxItem.getPagesSent()#</td></tr>
                <tr><th>Status</th><td>#currentFaxItem.getStatus()#</td></tr>
                <tr><th>Duration</th><td>#currentFaxItem.getDuration()#</td></tr>
                <tr><th>Subject</th><td>#currentFaxItem.getSubject()#</td></tr>
                <tr><th>PagesSubmitted</th><td>#currentFaxItem.getPagesSubmitted()#</td></tr>
                <tr><th>SenderCSID</th><td>#currentFaxItem.getSenderCSID()#</td></tr>
                <tr><th>Priority</th><td>#currentFaxItem.getPriority()#</td></tr>
                <tr><th>Units</th><td>#currentFaxItem.getUnits()#</td></tr>
                <tr><th>CostPerUnit</th><td>#currentFaxItem.getCostPerUnit()#</td></tr>
                <tr><th>PageSize</th><td>#currentFaxItem.getPageSize()#</td></tr>
                <tr><th>PageOrientation</th><td>#currentFaxItem.getPageOrientation()#</td></tr>
                <tr><th>PageResolution</th><td>#currentFaxItem.getPageResolution()#</td></tr>
                <tr><th>RenderingQuality</th><td>#currentFaxItem.getRenderingQuality()#</td></tr>
                <tr><th>PageHeader</th><td>#currentFaxItem.getPageHeader()#</td></tr>
                <tr><th>RetriesToPerform</th><td>#currentFaxItem.getRetriesToPerform()#</td></tr>
                <tr><th>TrialsPerformed</th><td>#currentFaxItem.getTrialsPerformed()#</td></tr>
                <tr><th>LocaleID</th><td>#currentFaxItem.getLocaleID()#</td></tr>
                <tr><th>GMTBias</th><td>#currentFaxItem.getGMTBias()#</td></tr>
                <tr><th>RetriesInterval</th><td>#currentFaxItem.getRetriesInterval()#</td></tr>
                <tr><th>UserData</th><td>#currentFaxItem.getUserData()#</td></tr>
                <tr><th>DeleteAfterUsage</th><td>#currentFaxItem.getDeleteAfterUsage()#</td></tr>
                <tr><th>Mode</th><td>#currentFaxItem.getMode()#</td></tr>
                <tr><th>NumOfTransactions</th><td>#currentFaxItem.getNumOfTransactions()#</td></tr>
                <tr><th>MessageID</th><td>#currentFaxItem.getMessageID()#</td></tr>
            </table>
            <br />
        </cfloop>

<cfelse>

    Error receiving fax items: #faxItems.getResultCode()#

</cfif>
</cfoutput>

Contact us today

Talk to a member of our team about the benefits InterFAX can bring to your organization's communications processes.

Contact us today