mauzer
02/27/2024, 2:40 PM<cfcomponent displayname="Beneficiaries" hint="ColdFusion Component for Add Beneficiaries">
<cffunction name="ProcessForm" access="remote" output="true" returntype="string" returnformat="plain">
<!---
Get the HTTP request body content.
NOTE: We have to use toString() as an intermediary method
call since the JSON packet comes across as a byte array
(binary data) which needs to be turned back into a string before
ColdFusion can parse it as a JSON value.
--->
<cfset requestBody = toString( getHttpRequestData().content ) />
<!--- Double-check to make sure it's a JSON value. --->
<cfif isJSON( requestBody )>
<!--- Echo back POST data. --->
<cfdump
var="#deserializeJSON( requestBody )#"
label="HTTP Body"
/>
<cfset myArrayObj = obj.fn>
<Cfdump var="#myArrayObj[1]#">
<cfquery name="myQuery" datasource="boi-interview-local">
INSERT INTO dbo.boi_beneficiaries (firstname)
VALUES(<cfqueryparam value="#myArrayObj[1]#" cfsqltype="CF_SQL_VARCHAR">)
</cfquery>
</cfif>
</cffunction>
</cfcomponent>
Many thanks