Skip to content

Instantly share code, notes, and snippets.

@sweded
Forked from nifl/record.cfm
Created November 19, 2012 21:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sweded/4114257 to your computer and use it in GitHub Desktop.
Save sweded/4114257 to your computer and use it in GitHub Desktop.
Queries QB record object.
<!---
Name: record.cfm
Author: Gernot Bartels
Description: Queries QB for record object.
If record ID exists, update;
Otherwise create new record.
Prevents duplicates.
History: Created
Added logic
Usage: Surveys, Intake,
Created: 2011-08-05
Updated: 2012-02-15
--->
<!--- return record object --->
<cfinvoke component="components.qbQuery" method="qFieldVal" returnvariable="recordObject">
<cfinvokeargument name="qbURL" value="#qbURL#" />
<cfinvokeargument name="theTable" value="#tableID#" />
<cfinvokeargument name="theTicket" value="#ticket#" />
<cfinvokeargument name="theToken" value="#token#" />
<cfinvokeargument name="theField" value="#uField#" />
<cfinvokeargument name="theValue" value="#uValue#" />
<cfinvokeargument name="theList" value="#uList#" />
</cfinvoke>
<!--- check returned object for record ID --->
<cfif isDefined("recordObject.qdbapi.record.XmlAttributes.rid")><!--- update record --->
<cfset recordID = #recordObject.qdbapi.record.XmlAttributes.rid# >
<cfinvoke component="components.qbAPI" method="updateRecord" returnvariable="Record">
<cfinvokeargument name="qbURL" value="#qbURL#" />
<cfinvokeargument name="tableID" value="#tableID#" />
<cfinvokeargument name="recordID" value="#recordID#" />
<cfinvokeargument name="content" value="#qb_xml#" />
<cfinvokeargument name="theTicket" value="#ticket#" />
<cfinvokeargument name="theToken" value="#token#" />
</cfinvoke>
<cfoutput>
from record update:</br>
#Record#</br>
</cfoutput>
<cfelse><!--- create record --->
<cfinvoke component="components.qbAPI" method="createRecord" returnvariable="Record">
<cfinvokeargument name="qbURL" value="#qbURL#" />
<cfinvokeargument name="tableID" value="#tableID#" />
<cfinvokeargument name="newRecord" value="#qb_xml#" />
<cfinvokeargument name="theTicket" value="#ticket#" />
<cfinvokeargument name="theToken" value="#token#" />
</cfinvoke>
<cfoutput>
from record create:</br>
#Record#</br>
</cfoutput>
</cfif>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment