• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

update 17 and split

New Here ,
Oct 24, 2024 Oct 24, 2024

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"

Views

246

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 25, 2024 Oct 25, 2024

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.

 

https://cffiddle.org/app/file?filepath=9f029a87-df43-4679-8ad1-e68e1aef64e4/af5419cf-9755-4f3a-998d-...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 27, 2024 Oct 27, 2024

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>

https://cffiddle.org/app/file?filepath=5149d2c1-49d1-4aca-879c-4e6ef33ff4c3/e3ecff66-71ce-4e00-bd2e-... 

BKBK_0-1730022530469.png

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 28, 2024 Oct 28, 2024

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>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 28, 2024 Oct 28, 2024

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>

 

https://cffiddle.org/app/file?filepath=9cf84e08-8565-43b6-b710-d8a0472bb9ac/73ad24d8-be36-4aa6-8586-... 

 

As you can see, it works as expected.

BKBK_0-1730141542688.png

 

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 28, 2024 Oct 28, 2024

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 29, 2024 Oct 29, 2024

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>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 29, 2024 Oct 29, 2024

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.

 

<cfloop query=#Q_ADResults#>
 
 
<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>
 
patrick_8394_0-1730249075344.png

Thanks for your time.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Oct 30, 2024 Oct 30, 2024

Copy link to clipboard

Copied

Try wrapping the value with toString() first, eg: toString(manager).split(",")[1]

 

--

Pete Freitag

Foundeo Inc.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 30, 2024 Oct 30, 2024

Copy link to clipboard

Copied

quote

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 30, 2024 Oct 30, 2024

Copy link to clipboard

Copied

LATEST

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>

 

 

 

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation