public
Last active — forked from nifl/record.cfm

Queries QB record object.

  • Download Gist
record.cfm
ColdFusion
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
<!---
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>

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.