Copy link to clipboard
Copied
applied update 17 to some of our dev servers and was told that certain code no longer works -
specifically when invoking the split command -
the below code is something being actively worked on - my concern is that there might be other things it could affect - is this unusual?
<cfif len(trim(manager)) gt 0>
<cfset mgr = manager.split(",")[1]/>
<cfset mgr = mgr.substring(3,len(mgr))/>
<cfset mgr_fname = mgr.split(' ')[1]/>
<cfset mgr_lname = mgr.split(' ')[2]/>
<cfelse>
<cfset mgr = ''/>
<cfset mgr_fname = ''/>
<cfset mgr_lname = ''/>
</cfif>
error from log:
Error","ajp-nio-127.0.0.1-8020-exec-9","10/24/24","11:00:00","HumanscaleHostSite","The split method was not found.Either there are no methods with the specified method name and argument types or the split method is overloaded with argument types that ColdFusion cannot decipher reliably. ColdFusion found 0 methods that match the provided arguments. If this is a Java object and you verified that the method exists, use the javacast function to reduce ambiguity. The specific sequence of files included or processed is: E:\internal\betahost.h\schedtasks\ad.cfm, line: 17"
Copy link to clipboard
Copied
None of those are CFML member functions, they are methods of `java.lang.String`. A pure CFML version of the above would be to use `listToArray()` and `mid`.
Having said that I wouldn't expect the behaviour to change. Judging my the error you mention of `The split method was not found.` I think the issue is that `manager` is not being set to a string at all.
Here is your code running on ACF2021 update 17 with no errors when manager is a string.
Copy link to clipboard
Copied
Like @aliaspooryorik , I too did a test on CFFiddle using Update 17 of ColdFusion 2021. There was no error.
<cfset manager ="John James Smith,Mary Jane Robinson">
<cfif len(trim(manager)) gt 0>
<cfset mgr = manager.split(",")[2]/>
<cfset mgr = mgr.substring(5,len(mgr))/>
<cfset mgr_middle_name = mgr.split(' ')[1]/>
<cfset mgr_last_name = mgr.split(' ')[2]/>
<cfelse>
<cfset mgr = ''/>
<cfset mgr_fname = ''/>
<cfset mgr_lname = ''/>
</cfif>
<cfoutput>
mgr_middle_name: #mgr_middle_name# <br>
mgr_last_name: #mgr_last_name#
</cfoutput>
Copy link to clipboard
Copied
Hi Support,
We do understand you run the code using hardcoded value for the manager string returning no error, and we ran the same, also no errors. However, the manager field / string values are returned from AD (Active Directory) using cfldap. Let me show you more in the code as below (removed the server name and creds for demonstration purpose).
The manager attribute from AD contains the value like this
CN=Maria Guadalupe López,OU=Human Resources,OU=Nogales,OU=Mexico,OU=North America,OU=Domain Users,OU=Offices,DC=humanscale,DC=com
In some cases, people’s name would have special characters in Spanish or French name, not sure if that would affect anything for the split function. We have changed to use mid function instead. But we were wondering the same code using the java split function worked with no errors before the update 17. Please let us know if you have any ideas. Thanks for your time.
<cfldap action="query"
server=""
name="Q_ADResults"
start=""
username=""
password=""
attributes ="createTimestamp,whenChanged,department, givenname,sn,cn,displayname,samaccountname,userprincipalname,lockoutTime,lockoutDuration,IsAccountLocked,title,mail,physicalDeliveryOfficeName,streetaddress,l,st,postalcode,co,c,hometelephone,telephoneNumber,mobile,fax,manager,ExtensionAttribute1"
scope="subtree">
<cfloop query=#Q_ADResults#>
<cftry>
<cfif len(trim(Q_ADResults.manager)) gt 0>
<cfset mgr = manager.split(",")[1]/>
<cfset mgr = mgr.substring(3,len(mgr))/>
<cfset mgr_fname = mgr.split(' ')[1]/>
<cfset mgr_lname = mgr.split(' ')[2]/>
<cfelse>
<cfset mgr = ''/>
<cfset mgr_fname = ''/>
<cfset mgr_lname = ''/>
</cfif>
<cfcatch>
<cfoutput>#Q_ADResults.manager#</cfoutput><br>
</cfcatch>
</cftry>
</cfloop>
Copy link to clipboard
Copied
Taking the hint from you, I ran the following code on CF2021 Update 17 on Cffiddle:
<cfset manager ="CN=Maria Guadalupe López,OU=Human Resources,OU=Nogales,OU=Mexico,OU=North America,OU=Domain Users,OU=Offices,DC=humanscale,DC=com">
<cfif len(trim(manager)) gt 0>
<cfset mgr = manager.split(",")[1]/>
<cfset mgr = mgr.substring(3,len(mgr))/>
<cfset mgr_fname = mgr.split(' ')[1]/>
<cfset mgr_mname = mgr.split(' ')[2]/>
<cfset mgr_lname = mgr.split(' ')[3]/>
<cfelse>
<cfset mgr = ''/>
<cfset mgr_fname = ''/>
<cfset mgr_mname = ''/>
<cfset mgr_lname = ''/>
</cfif>
<cfoutput>
mgr_fname: #mgr_fname# <br>
mgr_mname: #mgr_mname# <br>
mgr_lname: #mgr_lname# <br>
</cfoutput>
As you can see, it works as expected.
If you're still having an issue with this, then you will probably have to look elsewhere. For example, shouldn't the line
<cfset mgr = manager.split(",")[1]/>
be
<cfset mgr = Q_ADResults.manager.split(",")[1]/>
instead?
Copy link to clipboard
Copied
Hi Support,
We did try using the hardcoded for the below, and there is no error.
<cfset manager ="CN=Maria Guadalupe López,OU=Human Resources,OU=Nogales,OU=Mexico,OU=North America,OU=Domain Users,OU=Offices,DC=humanscale,DC=com">
But wondering the string returned from AD might have been different format or acting up diffrently? therefore the error shows split method not found, and was suggested to use javacast, but we did not have to before the update 17, which is the question in doubt why.
We tried this instead as you suggested, still same error.
<cfset mgr = Q_ADResults.manager.split(",")[1]/>
Thanks.
Copy link to clipboard
Copied
Thanks for your explanation. It made me look further. As a result, I can see a possible cause of the problem.
In the way we defined the variable Q_ADResults.manager, we treated Q_ADResults as a struct, hence overlooking the fact that it is a query.
Solution: in the loop, replace
Q_ADResults.manager
with
Q_ADResults.manager[currentrow]
That is, use
<cfloop query="Q_ADResults"> <!--- Using # not necessary--->
<cftry>
<cfset manager = trim(Q_ADResults.manager[currentrow])>
<cfif len(manager) gt 0>
<cfset mgr = manager.split(",")[1]/>
<cfset mgr = mgr.substring(3,len(mgr))/>
<cfset mgr_fname = mgr.split(' ')[1]/>
<cfset mgr_lname = mgr.split(' ')[2]/>
<cfelse>
<cfset mgr = ''/>
<cfset mgr_fname = ''/>
<cfset mgr_lname = ''/>
</cfif>
<cfcatch>
<cfoutput>#Q_ADResults.manager[currentrow]#</cfoutput><br>
</cfcatch>
</cftry>
</cfloop>
Copy link to clipboard
Copied
Hi Support,
Thanks for the suggestion. Unfortunately, we tried it, and still got the split method was not found error.
Thanks for your time.
Copy link to clipboard
Copied
Try wrapping the value with toString() first, eg: toString(manager).split(",")[1]
--
Pete Freitag
Copy link to clipboard
Copied
Thanks for the suggestion. Unfortunately, we tried it, and still got the split method was not found error.
<cfloop query=#Q_ADResults#>By @patrick_8394
As I said, change that line to
<cfloop query="Q_ADResults">
and apply Pete's suggestion, too.
Copy link to clipboard
Copied
I now suspect the error arises because ColdFusion is confusing the manager in variables scope with the manager in query scope. So, separate the concerns. For example, by introducing a new variable, currentManager, in variables scope.
To be clear, here's the suggestion in full
<cfloop query="Q_ADResults">
<cftry>
<cfset currentManager = trim(toString(Q_ADResults.manager[currentrow]))>
<cfif len(currentManager) gt 0>
<cfset mgr = currentManager.split(",")[1]/>
<cfset mgr = mgr.substring(3,len(mgr))/>
<cfset mgr_fname = mgr.split(' ')[1]/>
<cfset mgr_lname = mgr.split(' ')[2]/>
<cfelse>
<cfset mgr = ''/>
<cfset mgr_fname = ''/>
<cfset mgr_lname = ''/>
</cfif>
<cfoutput>
mgr_fname: #mgr_fname# <br>
mgr_lname: #mgr_lname# <br>
</cfoutput>
<cfcatch>
CurrentManager: <cfoutput>#currentManager#</cfoutput><br>
</cfcatch>
</cftry>
</cfloop>