Announcement

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

    resultSet.duplicate() this.newInstance is not a function

    I was trying to get my project issue records more cleanly from the resultSet that I created. I had been using findAll({}) to get them all into an array for filtering. When I changed to duplicate() I got the below error from the following code.
    Code:
    		var issueCriteria = { };
    		if (!(typeof tRec.IssueTypeID === "undefined")) {
    			issueCriteria.IssueTypeID = tRec.IssueTypeID;
    		}
    		if (!(typeof tRec.CategoryID === "undefined")) {
    			issueCriteria.CategoryID = tRec.CategoryID;
    		}
    		if (!(typeof tRec.ImpactID === "undefined")) {
    			issueCriteria.ImpactID = tRec.ImpactID;
    		}
    		Log.logDebug("************ filtering project issues with: " + this.echo(issueCriteria));
    		Log.logDebug("************ from " + Application.ProjectIssue.getLength() + " records");
    		//Log.logDebug("************ of which the first is " + this.echo(Application.ProjectIssue.get(0)));
    		var issueResults = [];
    		issueResults = Issue.applyFilter(Application.ProjectIssue.duplicate(), issueCriteria);
    Results in the following error.
    Code:
    12:34:31.305:TMR2:DEBUG:Log:************ issueGrid isc_ListGrid_0 created for topic# 1
    12:34:31.305:TMR2:DEBUG:Log:************ filtering project issues with: {ImpactID: 101}
    12:34:31.305:TMR2:DEBUG:Log:************ from 9 records
    12:34:31.321:TMR2:WARN:Log:TypeError: this.newInstance is not a function
        unnamed()
        getIssueGrid({Obj})
        ListGrid.expandRecord(_1=>{Obj})
        unnamed({Obj}, [object Array], {Obj})
        [c]Class.fireCallback(_1=>function (dsResponse, data, dsRequest),  _2=>"dsResponse,data,dsRequest",  _3=>[object Array],  _4=>{Obj},  _5=>undef)
        [c]Class.fireCallback(_1=>function (dsResponse, data, dsRequest),  _2=>"dsResponse,data,dsRequest",  _3=>[object Array])
        DataSource.fireResponseCallbacks({Obj}, {Obj}, {Obj}, {Obj})
        DataSource._completeResponseProcessing({Obj}, {Obj}, {Obj}, {Obj}, {Obj})
        DataSource._handleClientOnlyReply({Obj}, {Obj}, {Obj})
        [c]Class.fireCallback(_1=>{Obj},  _2=>"rpcResponse,data,rpcRequest",  _3=>[object Array],  _4=>{Obj},  _5=>undef)
        [c]Class.fireCallback(_1=>{Obj},  _2=>"rpcResponse,data,rpcRequest",  _3=>[object Array])
        [c]RPCManager.fireReplyCallback(_1=>{Obj},  _2=>{Obj},  _3=>{Obj},  _4=>{Obj})
        [c]RPCManager.fireReplyCallbacks(_1=>{Obj},  _2=>{Obj})
        [c]RPCManager.performOperationReply(_1=>{Obj},  _2=>{Obj})
        RPCManager._performTransactionReply(29)
        [c]Class.fireCallback(_1=>{Obj},  _2=>undef,  _3=>[object Array],  _4=>{Obj},  _5=>true)
        Timer._fireTimeout("$ir676")
        unnamed()
        unnamed() @
    What worked was the following, to which I will go back.
    Code:
    		var issueCriteria = { };
    		if (!(typeof tRec.IssueTypeID === "undefined")) {
    			issueCriteria.IssueTypeID = tRec.IssueTypeID;
    		}
    		if (!(typeof tRec.CategoryID === "undefined")) {
    			issueCriteria.CategoryID = tRec.CategoryID;
    		}
    		if (!(typeof tRec.ImpactID === "undefined")) {
    			issueCriteria.ImpactID = tRec.ImpactID;
    		}
    		Log.logDebug("************ filtering project issues with: " + this.echo(issueCriteria));
    		Log.logDebug("************ from " + Application.ProjectIssue.getLength() + " records");
    		//Log.logDebug("************ of which the first is " + this.echo(Application.ProjectIssue.get(0)));
    		var issueResults = [];
    		issueResults = Issue.applyFilter(Application.ProjectIssue.findAll({}), issueCriteria);
    Is there a more direct way (i.e. without criteria) to get resultSet records in an Array? And, if you are up to it, can you explain what is a 'shallow copy'?

    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
    A ResultSet has a lot of state to it, including potentially outstanding requests to the server and event handlers registered by components. duplicate() is not available for ResultSet because accurately duplicating all of this state would be very complex and in many cases the semantics of what *should* happen are not even clear, and there is no apparent use case for doing this.

    Obtaining the data from the ResultSet via findAll(), getAllVisibleRows() or getAllCachedRows() is probably what you should really do in the circumstance where you tried to call duplicate().

    Comment


      #3
      getAllCachedRows is not a function of resultSet in 8.2, I guess. I will stick with findAll for the moment. If getAllCachedRows is in 8.3 it will be another reason to trade up.

      Thanks,

      Rick

      Comment


        #4
        Yes, it was added in 8.3. Docs are here.

        Comment

        Working...
        X