Request vs Session Scope

I have a component performing SQL operations on a database.
At end of each function I set a REQUEST.msg which informs the user that the operation was a success and passes the ID number. The user is returned to the search form in Search or Edit mode. This works great for
Insert, select, and update but fails to persist for Delete function. The REQUEST.msg is not updated.

Example:
<cffunction name=“deleteRecord”
<cfquery>delte sql here </cfquery>
<cfset REQUEST.msg = “Record Deleted ID= this.id”>
</cffunction>

The only real difference in calling the function is that I am using “insert type=button onClick=…” to pass the id to the delete function vs using the submit button on the form. After the Delete operation I return the user to the search form using CFLocation.

Should I be using a SESSION variable rather than the REQUEST scope, or other scope variable?

Should I be using a SESSION variable rather than the REQUEST scope…?

From what you’ve described … neither IMO. The function shouldn’t modify those scopes directly. Nor should it mix UI code with db code. The function should return whatever value you want to the calling page (true/false, a new ID, etc…). Then the calling page should transform that value into some sort of status message for the user.

here is what I did to make it work.

… and now you’re displaying the same message for every user of the application.

I am not 100% sure I am using it correctly but here is what I did to make it work.

Added this(below) to my application.cfc and renamed from REQUEST.msg to application.msg.

<cffunction name=“onApplicationStart” returnType=“boolean” output=“false”>
<cfset application.msg = “”>
<cfreturn true>
</cffunction>