Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    DataSource.applyFilter seems not to be working.

    The code below is trying to populate 3 nested grids. My current problem is that I get ALL the project issue records after applying applyFilter criteria when I should only get one or two.

    Code:
    Log.setPriority("Log", 5);
    Log.logDebug("**** ProjectIssue version****************** OnlineMeetingButton.Click");
    
    OnlineMeetingWindow.autoDraw = false;
    OnlineAgendaGrid.autoDraw = false;
    
    var issueArray = [];
    issueArray = ProjectIssue.cacheData;
    Log.logDebug("************ ProjectIssue.cacheData record count: " + issueArray.length);
    
    if (!OnlineAgendaGrid) {Log.logDebug("************ OnlineAgendaGrid is undefined.");}
    
    MeetingTopic.fetchData( { "MeetingTypeID" : Application.currentMeetingTypeID },
        function (dsResponse, data, dsRequest) {
            Log.logDebug("************meeting topic records fetched: " + this.echo(dsResponse));
            if (dsResponse.status >= 0) {
                if (dsResponse.totalRows > 0) {
                    var totalTopics = dsResponse.totalRows;
                    for (var currentTopic = 0; currentTopic < totalTopics; currentTopic++) {
                        var currentTopicRecord = {};
                        currentTopicRecord = data[currentTopic];
                        //var currentTopicMember = OnlineAgendaGrid.getMember(currentTopic);
                        Log.logDebug("************ currentTopicRecord: " + this.echo(currentTopicRecord));
                        if (currentTopicRecord.SearchEnabled) {
                            var issueCriteria = "";
                            if (!(typeof currentTopicRecord.IssueTypeID === "undefined")) {
                                issueCriteria = "IssueTypeID: " + String(currentTopicRecord.IssueTypeID);
                            }
                            if (!(typeof currentTopicRecord.CategoryID === "undefined")) {
                                if (issueCriteria !== "") { issueCriteria = issueCriteria + ", "; }
                                issueCriteria = issueCriteria + "CategoryID: " + String(currentTopicRecord.CategoryID) ;
                            }
                            if (!(typeof currentTopicRecord.ImpactID === "undefined")) {
                                if (issueCriteria !== "") { issueCriteria = issueCriteria + ", "; }
                                issueCriteria = issueCriteria + "ImpactID: " + String(currentTopicRecord.ImpactID) ;
                            }
                            
                            var issueResults = ProjectIssue.applyFilter(issueArray, issueCriteria);
                            
                            Log.logDebug("************ ProjectIssue.applyFilter record count: " + issueResults.length + " for { " + issueCriteria + "}");
    						var issueCount = issueResults.length;
    						if (issueCount > 0) {
    							Log.logDebug("************ ProjectIssue.applyFilter issueResults[zero]: " + this.echo(issueResults[0]));
    							Log.logDebug("************ issueResults[zero]: " + this.echo(issueResults[0]));
    							
    							//currentTopicRecord.canExpand(true);
    							Log.logDebug("************ working with currentTopicRecord: " + this.echo(currentTopicRecord));
    							
    							var issueSubGrid = OnlineAgendaGrid.getExpansionComponent(currentTopicRecord);
    							if (issueSubGrid === null) {Log.logDebug("************ issueSubGrid is null.");}
    
    							issueSubGrid.canExpandRecords=true;
    							issueSubGrid.canExpandMultipleRecords=false;
    							issueSubGrid.expansionMode="related";
    							issueSubGrid.setData(issueResults);
    													
    							for (currentIssueIndex = 0; currentIssueIndex < issueCount; currentIssueIndex++) {
    								var currentIssueRecord = {};
    								currentIssueRecord = issueResults[currentIssueIndex];
    								Log.logDebug("************ currentIssueIndex = " + currentIssueIndex + " of " + issueCount);
    								Log.logDebug("************ currentIssueRecord = issueResults[" + currentIssueIndex + "]: " + this.echo(currentIssueRecord));
    								if (issueArray.remove(currentIssueRecord)) {
    									Log.logDebug("************ IssueNumber: " + currentIssueRecord.IssueNumber + " removed from issueArray");		
    								} else {
    									Log.logDebug("************ Error removing issue: " + this.echo(currentIssueRecord));
    								}				
    
    								currentIssueGridRecord = issueSubGrid.getRecord(currentIssueIndex);																			
    								currentIssueGridRecord.detailDS = "IncompleteTask";
    							}   // end for loop																								
    						} else {
    							Log.logDebug("************ issueCount is zero"); 
    							//currentTopicRecord.setProperty("canExpand", false);
    						} 	// end if issueCount is zero 
    					} else {
    						Log.logDebug("************ searchEnabled is false");  
    						// currentTopicRecord.setProperty("canExpand", false);
    					} 	// end if currentTopicRecord.SearchEnabled
    				} // end for currentTopic				
    			} else {
    				Log.logDebug("*********** No meeting topic records fetched for MeetingTypeID: " + Application.currentMeetingTypeID);	
                    isc.say("No meeting topic records fetched for MeetingTypeID: " + Application.currentMeetingTypeID);	
    			} // end if MeetingTopic.fetchData dsResponse.totalRows > 0		
    		} else {
    			Log.logDebug("*********** Error fetching meeting topic records for MeetingTypeID: " + Application.currentMeetingTypeID);	
                isc.say("Error fetching meeting topic records for MeetingTypeID: " + Application.currentMeetingTypeID);			
    		} // end if MeetingTopic.fetchData dsResponse.status >= 0			
    	} // end MeetingTopic.fetchData function
    );	// end MeetingTopic.fetchData call						
    Log.logDebug("************ done with MeetingTopic.fetchData call");
    
    if (!window.OnlineMeetingForm) {
        var message = "Component ID \"OnlineMeetingForm\", target of action \"Edit rec\" does not exist";
        isc.Log.logWarn(message);
        if (isc.designTime) {
            isc.say(message);
        }
    }
    
    OnlineMeetingForm.setValue("MeetingName", Application.currentMeetingName);
    OnlineMeetingForm.setValue("TeleconferenceInfo", Application.currentTeleconferenceInfo);
    
    OnlineAgendaGrid.canExpandRecords=true;
    OnlineAgendaGrid.canExpandMultipleRecords=false;
    OnlineAgendaGrid.expansionMode="related";
    OnlineAgendaGrid.childExpansionMode="related";
    OnlineAgendaGrid.detailDS="ProjectIssue";
    OnlineAgendaGrid.expansionRelatedProperties = { autoFetchData:true, autoFetchTextMatchStyle:"exact", canExpandRecords:true, canExpandMultipleRecords:false, detailDS:"IncompleteTask", height:"200", overflow:"visible"};
    OnlineAgendaGrid.markForRedraw("grids populated");
    
    OnlineMeetingWindow.setTitle("Project:" + Application.currentProjectNumber + " " + Application.currentMeetingName);
    OnlineMeetingWindow.markForRedraw("grids populated");
    OnlineMeetingWindow.show();
    
    Log.logDebug("****END***END***END*** OnlineMeetingButton.Click");
    You can see in the developer console below that a record count of 9 is returned for { ImpactID: 101}. Problem: the very first record returned (i.e. issueResults[zero]) has "ImpactID: 104,".

    Ironically, my complicated method of removing duplicate records is working. And, my command of a simple applyFilter call is not. Could the problem be with DataSource.fieldMatchesFilter?

    Code:
    17:47:05.718:TMR9:DEBUG:Log:************ ProjectIssue.applyFilter record count: 9 for { ImpactID: 101}
    17:47:05.719:TMR9:DEBUG:Log:************ ProjectIssue.applyFilter issueResults[zero]: {ProjectTitle: "SSN Suppression on checks for Universal ..."[54],
    Description: "A made up issue with category Cost, impa..."[64],
    CategoryName: "Schedule",
    CommunityID: 101,
    IssueTypeName: "Problem",
    ImpactName: "2-Moderate",
    IssueStatus: "Open",
    LikelihoodID: 101,
    IssueID: 107,
    IssueTitle: "Schedule L2 problem",
    IssueNumber: 4,
    ProjectNumber: "7633",
    Created: Date(01/30/2013),
    GoalStatus: "Y",
    ImpactID: 104,
    Log: "2012-04-23 NOTE comment for testing.",
    Modified: Date(07/23/2012),
    IssueTypeID: 101,
    CategoryID: 103,
    LikelihoodTitle: "5-Very Likely",
    OriginatorID: 101,
    ProjectID: 101,
    Private: false}
    17:47:05.722:TMR9:DEBUG:Log:************ issueResults[zero]: {ProjectTitle: "SSN Suppression on checks for Universal ..."[54],
    Description: "A made up issue with category Cost, impa..."[64],
    CategoryName: "Schedule",
    CommunityID: 101,
    IssueTypeName: "Problem",
    ImpactName: "2-Moderate",
    IssueStatus: "Open",
    LikelihoodID: 101,
    IssueID: 107,
    IssueTitle: "Schedule L2 problem",
    IssueNumber: 4,
    ProjectNumber: "7633",
    Created: Date(01/30/2013),
    GoalStatus: "Y",
    ImpactID: 104,
    Log: "2012-04-23 NOTE comment for testing.",
    Modified: Date(07/23/2012),
    IssueTypeID: 101,
    CategoryID: 103,
    LikelihoodTitle: "5-Very Likely",
    OriginatorID: 101,
    ProjectID: 101,
    Private: false}
    Bummer. Any ideas?

    Thanks,

    Rick

    P.S. I am running SmartClient Version: v8.2p_2013-01-14/EVAL Development Only on Mozilla Firefox 12.0 with Firebug using Windows XP Pro 32 bit.

    #2
    We would need the full DataSource definition and data set to tell (basically ready-to-run code), but applyFilter() is very unlikely to be at fault (hundreds of automated tests cover that method).

    Instead, check for errors such as criteria that refers to fields that don't exist in the DataSource, and remember that field names are case sensitive.

    Comment


      #3
      It was a bonehead mistake. I built the string but forgot to put it in an object. So, I just changed the code to build the criteria object directly. Much easier code and it works fine.

      It wasn't a typo, it was a thinko.

      Rick

      Comment

      Working...
      X