Page 1 of 1

Custom Populate Fields Extension Selects All Conditional Info Blocks in Error

Posted: Mon May 17, 2021 6:13 pm
by StevenSevic
The following code should act like the Populate Fields extensions, in that it selects a value in a drop down or radio list, and then omits all other choices so that conditional text information blocks can be triggered. For some reason, this script selects the proper choices, omits all other choices, and looks to appear to function correctly, however all conditional blocks of information are displayed instead of just the correct conditional block.

The following is my code, and any help is appreciated!

Code: Select all


<cfcomponent extends="istart.core.EFormExtension">

	<!--- returns a boolean indicating if the service is supported for the given identifier
	thus this can limit service access to specific groups (i.e. F-1 students) --->
	<cffunction name="isSupported" access="public" returntype="boolean">
		<cfargument name="identifier" type="istart.core.Identifier" required="true">
		<cfscript>
			var supported = true;
		</cfscript>
		<cfreturn supported>
	</cffunction>

	<!--- returns a collection of code value datum types for this particular implementation;
	or by default returns an empty collection --->
	<cffunction name="getCodes" access="public" returntype="istart.core.DatumType[]">
		<cfargument name="tableNameValue" type="string" required="true">
		<cfscript>
			var codeValues = ArrayNew(1);
			var codeSet = createObject("component", "istart.core.CodeSet");
		</cfscript>
		<cfreturn codeValues>
	</cffunction>
	
	
	<!--- modifies a service implementation for the given identifier upon generation
	of the service before the view is generated for the user --->
	<cffunction name="modifyService" access="public">
		<cfargument name="identifier" type="istart.core.Identifier" required="true">
		<cfargument name="index" type="string" required="true">
		<cfargument name="service" type="istart.core.Service" required="true">
		
			<cfquery name="contentPRQuery">
			SELECT jbCustomFields9.idnumber, jbCustomFields9.customField1
			FROM jbCustomFields9
			WHERE jbCustomFields9.idnumber = <cfqueryparam cfsqltype="cf_sql_integer" value="#identifier.getIDNumber()#">
			</cfquery>				

			<cfscript>
				//ACADEMIC CAREER SELECTOR
				//------------------------
				if(contentPRQuery.recordCount gt 0) {
					var contentPRRadioElement = service.getFormObject().getFirstElementByMetaInfo("contentPRRadio");
					
					var RadioOption = CreateObject("component","istart.core.DatumType");

					if(contentPRQuery.customField1 eq "track1") {
						RadioOption.setKey("Regular Processing");
						RadioOption.setValue("Regular Processing");
					}
					if(contentPRQuery.customField1 eq "track2") {
						RadioOption.setKey("Outstanding Researcher");
						RadioOption.setValue("Outstanding Researcher");
					}
					if(contentPRQuery.customField1 eq "track3") {
						RadioOption.setKey("Special Handling");
						RadioOption.setValue("Special Handling");
					}
					if(contentPRQuery.customField1 eq "track4") {
						RadioOption.setKey("Outstanding Researcher or Special Handling");
						RadioOption.setValue("Outstanding Researcher or Special Handling");
					}
					if(contentPRQuery.customField1 eq "error") {
						RadioOption.setKey("Error");
						RadioOption.setValue("Error");
					}
					ArrayClear(contentPRRadioElement.getReferences());
						contentPRRadioElement.addReference(RadioOption);

						if(contentPRQuery.customField1 eq "track1") {
							contentPRRadioElement.setValue("Regular Processing");
						}
						if(contentPRQuery.customField1 eq "track2") {
							contentPRRadioElement.setValue("Outstanding Researcher");
						}
						if(contentPRQuery.customField1 eq "track3") {
							contentPRRadioElement.setValue("Special Handling");
						}												
						if(contentPRQuery.customField1 eq "track4") {
							contentPRRadioElement.setValue("Outstanding Researcher or Special Handling");
						}
						if(contentPRQuery.customField1 eq "error") {
							contentPRRadioElement.setValue("Error");
						}
				}
				else {
				// what do you want to do if the student has nothing selected or nothing defined?

				}
				
			</cfscript>

	</cffunction>


	<!--- returns an idnumber based upon information on the form object; which is to be
	used in cases to determine the proper idnumber (i.e. special departmental eforms) --->
	<cffunction name="getFormObjectIDNumber" access="public" returntype="numeric">
		<cfargument name="formObject" type="istart.core.FormObject" required="true">
		<cftry>
		<cfreturn url.idnumber>
			<cfcatch>
			<cfreturn 0>
			</cfcatch>
		</cftry>
		<cfreturn 0>
	</cffunction>

</cfcomponent>