Gregory's Blog

ColdFusion error: "The current user is not authorized to invoke this method."

I wanted to document this as this error is not often found using google, but if you receive a ColdFusion error "The current user is not authorized to invoke this method.", it could be due to using the roles attribute in a cfffunction tag that don't match the roles that you set using the cflogin tag upon successful login.

I received this error when converting the original application.cfm tag in BlogCfc to use an application.cfc instead. During the conversion processes, I noticed that there was a 'roles' argument on the cffunction that did not match up with the new role that I had just programmed in the cflogin logic. When I searched for this error, I found a bunch of errors relating to using ColdFusions built in administrative user interface, and could not find that it was due to the role restrictions on the cffunction tag and thought to document it. It is a relatively intuitive error, but I am surprised that Adobe did not elaborate and write something like 'The role on the function does not match the cflogin role'. ColdFusion has always been good at that.

If you receive this error, check the roles attributes that you have used. It will likely fix the problem.

This entry was posted on June 2, 2019 at 2:32 PM and has received 178 views.

There are currently 0 comments.

Shorthand struct return

There are many ways to return multiple values from a cfc. Typically we return a query object, a json string, an array, or a structure, but one of my favorite ways to return multiple bits of data is using a shorthand structure. It is much easier and intuitive to use on both the back and front end than using an array. Here is a simple example:


view plain about
1<!--- There are two types of routing titles. The original design used an routing title that was used to populate a contract and this title was not the official title, but something more generic that was easily identifiable on a written contract. The other title is the official title that is coming from the workday database We will use the original routing title if the user was assigned a routing title that is found in the routing database, otherwise, we will use the official workday title. --->
2 <cffunction name="getTitleByEmail" access="remote" returntype="struct" hint="Determines the approver title. This will be either the routing title that was used in previous contracts, or the official title found in workday. We need to return multiple values, so this returns a one dimension array instead of a string.">
3 <cfargument name="email" type="string" required="yes" hint="Supply the email.">
5 <cfparam name="title" default="">
7 <!---Format the email--->
8 <cfinvoke component="#WorkdayUsersObj#" method="formatUwEmail" returnvariable="uwEmail">
9     <cfinvokeargument name="email" value="">
10        </cfinvoke>
12 <!--- Query the Approval database to see if the title exists. --->
13 <cfquery name="approvalTitle" datasource="Contracts">
14     SELECT TOP (1)
15                ApproverTitle
16                FROM dbo.Approval
17                WHERE (Email = <cfqueryparam value="#uwEmail#" cfsqltype="cf_sql_varchar">)
18 </cfquery>
19 <!---Set the ApproverTitle--->
20 <cfset ApproverTitle = approvalTitle.ApproverTitle>
21         <!---Get the workday job title. --->
22         <cfinvoke component="#WorkdayUsersObj#" method="getEmployeeJobTitle" returnvariable="workdayTitle">
23            <cfinvokeargument name="email" value="#email#">
24         </cfinvoke>
26 <!---Build the shorthand struct --->
27 <cfset titleStruct = {workdayTitle = #workdayTitle#, ApproverTitle = #ApproverTitle#}>
29 <cfreturn titleStruct>
31 </cffunction>

On the client side, simply use the following to output the value:

view plain about
1<cfset thisRoutingTitle = getTitleByEmail(thisApproverEmail).ApproverTitle>
2<cfset thisWorkdayTitle = getTitleByEmail(thisApproverEmail).WorkdayTitle>

This entry was posted on December 14, 2018 at 12:34 PM and has received 31 views.

There are currently 0 comments.

Localization Support Dropped

I am going to forgo using Raymond's localization support for this version. To incorporate a few languages, Raymond uses the resourceBundle.cfc template that was originally coded by Paul Hastings. I believe that it supports two variants Dutch and German languages, along with English of course. Raymond labels his buttons and text messages in the different languages in 4 different .properties files, and uses the 'rb('message var') function to display the text and messages. I have decided not to incorporate the localization as I can't translate between English and the other languages, and this blog is also intended to be a living example how to use Kendo with ColdFusion. Using 'rb('pleaseWait') in my code will be confusing to the reader wanting to know how I am using ColdFusion and Kendo. It is much easier to read:

view plain about
1'$.when({ title: "Please wait...", message: "Searching.", icon: "k-ext-information" }));'
view plain about
1'$.when({ title: "<cfoutput>#rb(pleaseWait)#</cfoutput>", message: "<cfoutput>#rb(searching)#</cfoutput>", icon: "k-ext-information" }));'
for example. In one of the next versions, if someone wants to assist me in translating the English into the supported languages, I may revisit this decision and incorporate localization into the code.

This entry was posted on December 8, 2018 at 11:15 PM and has received 45 views.

There are currently 0 comments.

Your input and contributions are welcomed!

If you have an idea, BlogCfc based code, or a theme that you have built using this site that you want to share, please contribute by making a post here or share it by contacting us! This community can only thrive if we continue to work together.

Images and Photography:

Gregory Alexander either owns the copyright, or has the rights to use, all images and photographs on the site. If an image is not part of the "Gregory's Blog" open sourced distribution package, and instead is part of a personal blog post or a comment, please contact us and the author of the post or comment to obtain permission if you would like to use a personal image or photograph found on this site.


Portions of Gregory's Blog are powered on the server side by BlogCfc, an open source blog developed by Raymond Camden. Revitalizing BlogCfc was a part of my orginal inspiration that prompted me to design this site. Some of the major open source contributers to BlogCfc include:

  1. Peter Farrell: the author of 'Lyla Captcha' that is used on this blog.
  2. Pete Freitag: the author of the 'ColdFish' code formatter that is also used on this blog.


Gregory's Blog Version 1.01 June 13, 2019 00:49 PST.