I created a UDF that works fine when I call it thu...
# cfml-beginners
n
I created a UDF that works fine when I call it thusly: <cfoutput> #getvocab("6700.6")# </cfoutput> I am having some difficulty using it to perform the function on an XML item: #getVocab(xmlDoc.TreatmentEpisode.ProviderTreatmentEpisodes.Episdoe[MainIndex].FirstContactExpCode)# It seems to return nothing. So I don't think I am passing the value of the XML node in correctly. What am I doing wrong or what should I look at to test. The function is full of awfulness, but I will post it if it would be helpful. If it is the way I am passing the argument, is there an easy rule of thumb to remember when to do what? TIA
a
Can you pls create a SSCCE in trycf, instead of describing your code? http://sscce.org/
n
This code and test works:
Copy code
<cfoutput><p>TheVocab for 6700.6 IS: [ #getvocab("6700.6")# ]</p></cfoutput></br>


<cffunction name="GetVocab" returntype="string">
	<Cfargument required="yes" type="any" name="VocabLookup">

	<cfquery name="qryvcheck" dbtype="query">
		Select ConceptCode,Term_FullySpecifiedName from qryVocab where conceptcode = '#VocabLookup#'
	</cfquery>
	
	<cfif qryvcheck.recordcount GTE 2>
		<cfoutput><p>Too many records: #qryvcheck.recordcount# </p> </cfoutput>
	</cfif>

	<cfset VocabReturn= qryvcheck.Term_FullySpecifiedName[1]>
	<Cfreturn VocabReturn>
</cffunction>
a
OK, did you notice the "trycf" and "SSCCE" bits? Write some stand-alone code (incl all inputs), that runs in trycf and shows the problem. Link to that.
n
This code does not work:
Copy code
#getvocab(XMLDoc.TreatmentEpisodeDataSet.ProviderTreatmentEpisodes.ProviderTreatmentEpisode[MainIndex].ReferralSourceCode)#
a
Nate, I can't help you if you don't read what I say.
e
https://trycf.com/ <--- Put code here
✔️ 1