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?
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>");
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>");
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.
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
Copy link to clipboard
Copied
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:
3. Click on the Core Admin menu. Select the collection and press the Reload button.