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

CF Admin API - collections

New Here ,
Mar 07, 2023 Mar 07, 2023

Copy link to clipboard

Copied

I am trying to access the collections api for the CF Admin and have a question.  I am executing a call to the reloadCollection method but it does not appear to return any value.  Here is a sample snippet of the code I am trying to execute/

collectionObj = createObject("component","cfide.adminapi.collections");
collectionObj.reloadCollection("testCollection");

The above executes without issue but if I try setting the method call to a variable and then try and dump the variable the code generates an error that the variable was undefined.

tempTest = collectionObj.reloadCollection("testCollection");
writeDump(var="#tempTest#",format="html");

Is there a way to determine if the call has executed successfully? 

TOPICS
Server administration

Views

289

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

correct answers 1 Correct answer

Community Expert , Mar 08, 2023 Mar 08, 2023

The variable is undefined because reloadCollection() has void return-type.

You could test for a successful reload as follows:

 

try {
	collectionObj = createObject("component","cfide.adminapi.collections");
	collectionObj.reloadCollection("testCollection");	
	collectionReloaded=true;
} catch (any xception) {
	collectionReloaded=false;
	//writedump(var=xception, label="ReloadCollection failure");
}
writeoutput("<p>Is testCollection reloaded: " & collectionReloaded & "</p>");

 

 

Votes

Translate

Translate
Community Expert ,
Mar 08, 2023 Mar 08, 2023

Copy link to clipboard

Copied

The variable is undefined because reloadCollection() has void return-type.

You could test for a successful reload as follows:

 

try {
	collectionObj = createObject("component","cfide.adminapi.collections");
	collectionObj.reloadCollection("testCollection");	
	collectionReloaded=true;
} catch (any xception) {
	collectionReloaded=false;
	//writedump(var=xception, label="ReloadCollection failure");
}
writeoutput("<p>Is testCollection reloaded: " & collectionReloaded & "</p>");

 

 

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 ,
Mar 08, 2023 Mar 08, 2023

Copy link to clipboard

Copied

BKBK - okay I was expect some type of return as when I dump the collectionObj it says the return type is "Any".  Definitely appreciate the code snippet. 

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 ,
Mar 08, 2023 Mar 08, 2023

Copy link to clipboard

Copied

I can see the confusion. It is caused because a returntype of "any" includes "void".

 

That API documentation should indeed have been more specific. I have created a bug report: https://tracker.adobe.com/#/view/CF-4217254 

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 ,
Mar 08, 2023 Mar 08, 2023

Copy link to clipboard

Copied

LATEST

Is there a way to determine if the call has executed successfully? 


By @usmc-ret

 

There is a workaround that does not involve code. It goes as follows:

  1.  Open the ColdFusion Administrator. Navigate to Data & Services > Solr Server. Read off the Solr port number. Mine is 8993.
    BKBK_1-1678294476389.png

     




     
     
  2.  Launch the following URL in the browser: http://127.0.0.1:{portNumber}/solr/#/ 
         In my case, this is: http://127.0.0.1:8993/solr/#/ 
    BKBK_0-1678294443008.png

     


     

     

    3. Click on the Core Admin menu. Select the collection and press the Reload button.

    BKBK_2-1678294540901.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
Resources
Documentation