Passing the form scope to a Remote cfc

Posted by cf_PhillipSenn on Stack Overflow See other posts from Stack Overflow or by cf_PhillipSenn
Published on 2010-03-29T23:50:48Z Indexed on 2010/03/29 23:53 UTC
Read the original article Hit count: 198

Filed under:
|

What is the syntax for passing the form scope into a cfc with access="remote"? I have:

<cfcomponent>
<cfset Variables.Datasource = "xxx">

<cffunction name="Save" access="remote">
    <cfset var local = {}>

    <!--- todo: try/catch --->  
    <cfif arguments.PersonID>
        <cfquery datasource="#Variables.Datasource#">
        UPDATE Person
        SET FirstName = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.FirstName#">
        ,LastName = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.LastName#">
        WHERE PersonID = <cfqueryparam cfsqltype="cf_sql_integer" value="#arguments.PersonID#">
        </cfquery>
        <cfset local.result = arguments.PersonID>
    <cfelse>
        <cfquery name="local.qry" datasource="#Variables.Datasource#">
        INSERT INTO Person(FirstName,LastName) VALUES(
        <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.FirstName#">
        ,<cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.LastName#">
        );
        SELECT PersonID FROM Person 
        WHERE PersonID=Scope_Identity()
        </cfquery>
        <cfset local.result = local.qry.PersonID>
    </cfif>
    <cfreturn local.result>
</cffunction>
</cfcomponent>

I need to pass in form.PersonID, form.firstname, form.lastname.

© Stack Overflow or respective owner

Related posts about coldfusion

Related posts about AJAX