Announcement

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

    fetch with operationId being ignored

    I am running SmartClient Version: SmartClient_v8.2p_2012-06-08/EVAL (Deployment 2012-06-08) on Mozilla Firefox 3.6.18 with Firebug using Windows XP Pro 32 bit.

    For a SelectItem I need to do a negative join. I want to show a list of teammembers to add to a list of stakeholders that are not already a stakeholder. This needs a special fetch, and the cache needs to be invalidated each time.

    Before I open the window with the FormItem I call TeamMember.invalidateCache for the datasource and also for the formitem display values. When I show the window, for the FormItem I get an RPCrequest that fetches all the TeamMembers (even though I have turned off AutoFetchData).

    Code:
    {
        "actionURL":"http://localhost:8080/isomorphic/IDACall", 
        "showPrompt":true, 
        "transport":"xmlHttpRequest", 
        "promptStyle":"dialog", 
        "bypassCache":true, 
        "data":{
            "criteria":null, 
            "operationConfig":{
                "dataSource":"TeamMember", 
                "repo":null, 
                "operationType":"fetch"
            }, 
            "appID":"builtinApplication", 
            "operation":"TeamMember_fetch", 
            "oldValues":null, 
            "streamResults":null, 
            "exportToFilesystem":null, 
            "exportToClient":null
        }
    }
    This has a DSrequest:
    Code:
    {
        "dataSource":"TeamMember", 
        "operationType":"fetch", 
        "data":null, 
        "resultSet":[ResultSet ID:isc_ResultSet_13 (created by: undefined)], 
        "callback":{
            "caller":[ResultSet ID:isc_ResultSet_13 (created by: undefined)], 
            "methodName":"fetchRemoteDataReply"
        }, 
        "willHandleError":true, 
        "showPrompt":true, 
        "oldValues":null, 
        "clientContext":{
            "requestIndex":1
        }, 
        "requestId":"TeamMember$62714"
    }
    I don't mind this, because when the form loads I catch visibilityChanged and try to invalidate the cache again. Then I force a fetchData with an operationId to "excludeCurrentStakeholders".
    Code:
        if (this.isVisible()) {
            this.getField("TEAMMEMBERID").fetchMissingValues = true;
            this.getField("TEAMMEMBERID").alwaysFetchMissingValues = true;
            this.getField("TEAMMEMBERID").optionOperationId = "excludeCurrentStakeholders";
            this.getField("TEAMMEMBERID").optionCriteria = {'Project.ProjectID': Application.currentProjectID, 'Stakeholder.CommunityID': Application.currentCommunityID, 'TeamMember.CommunityID': Application.currentCommunityID};
            this.getField("TEAMMEMBERID").invalidateDisplayValueCache();
            this.getField("TEAMMEMBERID").fetchData(function (dsItem, dsResponse, dsData, dsRequest) {isc.say("this.getField(TEAMMEMBERID).fetchData " + this.echo(dsRequest));}, {operationId: "excludeCurrentStakeholders", operationType: "fetch"});
        }
    This is the result
    Code:
    {
        "actionURL":"http://localhost:8080/isomorphic/IDACall", 
        "showPrompt":false, 
        "prompt":"Finding records that match your criteria...", 
        "transport":"xmlHttpRequest", 
        "promptStyle":"dialog", 
        "params":{
            "Project.ProjectID":101, 
            "Stakeholder.CommunityID":101, 
            "TeamMember.CommunityID":101
        }, 
        "httpMethod":"GET", 
        "bypassCache":true, 
        "callback":{
            "target":[DataSource ID:TeamMember], 
            "methodName":"$50e"
        }, 
        "willHandleError":true, 
        "clientContext":{
            "requestIndex":1, 
            "$69t":null
        }, 
        "data":null
    }
    Code:
    {
        "dataSource":"TeamMember", 
        "operationType":"fetch", 
        "operationId":"excludeCurrentStakeholders", 
        "componentId":"isc_PickListMenu_3", 
        "data":{
            "Project.ProjectID":101, 
            "Stakeholder.CommunityID":101, 
            "TeamMember.CommunityID":101
        }, 
        "startRow":0, 
        "endRow":75, 
        "textMatchStyle":"startsWith", 
        "resultSet":[ResultSet ID:isc_ResultSet_12 (created by: isc_PickListMenu_3)], 
        "callback":{
            "caller":[ResultSet ID:isc_ResultSet_12 (created by: isc_PickListMenu_3)], 
            "methodName":"fetchRemoteDataReply"
        }, 
        "willHandleError":true, 
        "showPrompt":false, 
        "prompt":"Finding records that match your criteria...", 
        "clientContext":{
            "requestIndex":1
        }, 
        "requestId":"TeamMember$62713"
    }
    I notice in the RPC list that this last entry shows "[client only]" in the URL. This seems to be ignoring the call to throw away the cache and use the operationId. This agrees with the result because, I get all the TeamMembers every time in the drop down list.

    Here is the ds.xml
    Code:
    <DataSource ID="TeamMember" dataFormat="iscServer" serverType="sql" dataSourceVersion="1" dbName="PlanetProjectDB" schema="PUBLIC" autoDeriveSchema="true">
        <fields>
            <field name="TEAMMEMBERID" type="sequence" primaryKey="true"/>
            <field name="COMMUNITYID" type="text" required="true" title="Community" canEdit="false" foreignKey="Community.COMMUNITYID"/>
            <field name="TEAMMEMBERNAME" type="text" required="true" length="64" title="Name" canEdit="true"/>
            <field name="ENABLED" type="boolean" required="true" title="Enabled" canEdit="true"/>
            <field name="TEAMMEMBEREMAIL" type="text" length="64" title="Email" canEdit="true"/>
            <field name="EMAILCONFIRMED" type="boolean" required="true" title="Confirmed" canEdit="false"/>
            <field name="ORGANIZATIONID" type="text" required="true" title="Organization" canEdit="true" foreignKey="Organization.ORGANIZATIONID"/>
            <field name="BASEPHONE" type="text" length="64" title="Phone" canEdit="true"/>
            <field name="MOBILEPHONE" type="text" length="64" title="Mobile" canEdit="true"/>
            <field name="BASELOCATION" type="text" length="64" title="Location" detail="true" canEdit="true"/>
            <field name="BASETIMEZONE" type="text" length="64" title="Time Zone" detail="true" canEdit="true"/>
            <field name="BASELANGUAGE" type="text" length="64" title="Language" detail="true" canEdit="true"/>
            <field name="BASENUMBERFORMAT" type="text" length="64" title="Number Format" detail="true" canEdit="true"/>
            <field name="BASEDATEFORMAT" type="text" length="64" title="Date Format" detail="true" canEdit="true"/>
            <field name="COMMUNITYADMIN" type="boolean" title="Admin" detail="false" canEdit="true"/>
            <field name="LOG" type="text" length="2147483647" title="Log" detail="true"/>
            <field name="CREATED" type="creatorTimestamp" title="Created" detail="true"/>
            <field name="MODIFIED" type="modifierTimestamp" title="Modified" detail="true"/>
        </fields>
        <operationBindings>
            <OperationBinding operationType="fetch" operationId="excludeCurrentStakeholders">
                <tableClause>TeamMember CROSS JOIN Project LEFT JOIN Stakeholder ON Stakeholder.TeamMemberID = TeamMember.TeamMemberID AND Project.ProjectID = Stakeholder.ProjectID </tableClause>
                <whereClause>Stakeholder.TeamMemberID IS NULL AND ($defaultWhereClause)</whereClause>
                <invalidateCache>true</invalidateCache>
            </OperationBinding>
        </operationBindings>
        <cacheAllData>false</cacheAllData>
        <title>TeamMember</title>
        <titleField>TEAMMEMBERNAME</titleField>
        <pluralTitle>TeamMembers</pluralTitle>
        <generatedBy>SC_SNAPSHOT-2012-01-09_v8.2p/Pro Deployment 2012-01-09</generatedBy>
    </DataSource>
    and the code on the button
    Code:
        if (!window.ProjectStakeholderWindow) {
            var message = "Component ID \"ProjectStakeholderWindow\", target of action \"Show\" does not exist";
            isc.Log.logWarn(message);
            if (isc.designTime) {
                isc.say(message);
            }
        }
        var form = ProjectStakeholderForm;
        form.clearValues();
        form.setValue("COMMUNITYID", Application.currentCommunityID);
        form.setValue("PROJECTID", Application.currentProjectID);
        form.setValue("PROJECTADMIN", false);
        form.rememberValues();
        form.setSaveOperationType("add");
        form.getItem("SaveButton").setDisabled(true);
        form.getItem("UndoButton").setDisabled(true);
        TeamMember.invalidateCache();
        ProjectStakeholderWindow.show();
        ProjectStakeholderWindow.setTitle("New Stakeholder for Project " + Application.currentProjectNumber + ": " + Application.currentProjectTitle);
    The server log agrees with the RPC log. There is no fetch with the operationId. It is attached.

    I can test around this by just not selecting to add a duplicate. But, I cannot find a work around in code.

    I appreciate the attempt at optimization by using the cache a lot. But, I need to turn it off somehow in this instance.

    I little help would go a long way.

    Thanks,

    Rick
    Attached Files

    #2
    The correct way to set the optionOperationId is to set it on the SelectItem when you pass it to the form, and not try to change it after the fact.

    There's no need for any of these invalidateCache() calls or anything of the kind.

    Comment


      #3
      I appreciate the quick reply. I did not start out trying to invalidate the cache. Initially, I just set the optionOperationId as you recommend. I verified this and turned off everything else. No dice. I still get all the teammembers and I know that the join works because I created and tested it in Eclipse.
      Code:
      <DynamicForm numCols="4" dataSource="Stakeholder" ID="ProjectStakeholderForm" autoDraw="false">
          <fields>
              <FormItem name="TEAMMEMBERID" title="Team Member" constructor="SelectItem">
                  <valueField>TEAMMEMBERID</valueField>
                  <displayField>TEAMMEMBERNAME</displayField>
                  <optionDataSource><DataSource ref="TeamMember"/></optionDataSource>
                  <optionOperationId>excludeCurrentStakeholders</optionOperationId>
                  <autoFetchData>false</autoFetchData>
              </FormItem>
              <FormItem name="PROJECTID" constructor="HiddenItem"/>
              <FormItem editorType="text" name="ROLE" title="Role" constructor="TextItem">
                  <valueField></valueField>
                  <displayField></displayField>
              </FormItem>
              <FormItem name="PROJECTADMIN" title="Admin" constructor="CheckboxItem"/>
              <FormItem name="DESC" title="Description" constructor="TextItem">
                  <startRow>true</startRow>
              </FormItem>
              <FormItem name="CREATED" title="Created" constructor="TextItem">
                  <startRow>true</startRow>
              </FormItem>
              <FormItem name="MODIFIED" title="Modified" constructor="TextItem"/>
      I did note in the RPC log that the operationId was being communicated. Hence my conclusion that it was being ignored. I set it on the selectItem on the button event, when the form becomes visible, and natively (like you said) on the selectItem when it is defined.

      OK. This is weird. In the attached RPC log image I note that it shows the component to be <ProjectForm.PROJECTMANAGERID>. In fact it should be <ProjectStakeholderForm.TEAMMEMBERID>. Maybe the problem is that these two formitems are sharing a picklist?

      It is obvioiusly incorrect, seeing as how the PROJECTMANAGERID has no optionOperationId
      Code:
      <DynamicForm numCols="9" dataSource="Project" ID="ProjectForm" autoDraw="false">
          <fields>
              <FormItem name="PROJECTID" title="Projectid" constructor="TextItem">
                  <visible>false</visible>
              </FormItem>
              <FormItem name="COMMUNITYID" title="Community" constructor="TextItem">
                  <visible>false</visible>
              </FormItem>
              <FormItem name="PROJECTNUMBER" title="Project" constructor="TextItem"/>
              <FormItem name="PROJECTTITLE" title="Title" constructor="TextItem">
                  <colSpan>3</colSpan>
              </FormItem>
              <FormItem name="DESC" title="Description" constructor="TextAreaItem">
                  <titleOrientation>top</titleOrientation>
                  <width>*</width>
                  <height>60</height>
                  <colSpan>5</colSpan>
                  <rowSpan>2</rowSpan>
                  <startRow>true</startRow>
                  <disabled>false</disabled>
              </FormItem>
              <FormItem name="TASKORDER" title="Task Order" constructor="TextItem"/>
              <FormItem name="INACTIVE" title="Inactive" constructor="CheckboxItem"/>
              <FormItem name="OWNINGPROJECTID" title="Owning Project#" constructor="SelectItem">
                  <valueField>PROJECTID</valueField>
                  <displayField>PROJECTNUMBER</displayField>
                  <optionDataSource><DataSource ref="Project"/></optionDataSource>
              </FormItem>
              <FormItem name="PROJECTMANAGERID" title="Project Manager" constructor="SelectItem">
                  <valueField>TEAMMEMBERID</valueField>
                  <displayField>TEAMMEMBERNAME</displayField>
                  <optionDataSource><DataSource ref="TeamMember"/></optionDataSource>
                  <autoFetchData>true</autoFetchData>
              </FormItem>
      I would post a standalone case if I knew how to build it.

      Rick
      Attached Files

      Comment

      Working...
      X