Applying condition to a model in javascript returns the wrong record

  • 1
  • Problem
  • Updated 4 years ago
We have a model that we are trying to filter with two conditions. We applied both conditions. When we look in the object, we can see that both conditions were correctly applied but, the row that is filtered does not match the conditions. Any advice?



 = skuid.model.getModel('MMA_Payroll_Period_Instructor_Day')
K {updateable: true, type: "", soql: "SELECT Payroll_Day_Date__c,Name,MMA_Payroll_Period...FROM MMA_Payroll_Period_Instructor_Day__c LIMIT 2", rTypeFor: null, recordTypeInfos: null...}
y.getConditionByName('MMA_Instructor__c')
Object {valueTemplate: null, values: null, value: "", units: null, type: "fieldvalue"...}
y = skuid.model.getModel('MMA_Payroll_Period_Instructor_Day')

K {updateable: true, type: "", soql: "SELECT Payroll_Day_Date__c,Name,MMA_Payroll_Period...FROM MMA_Payroll_Period_Instructor_Day__c LIMIT 2", rTypeFor: null, recordTypeInfos: null...}
Instructor_condition = y.getConditionByName('MMA_Instructor__c')
Object {valueTemplate: null, values: null, value: "", units: null, type: "fieldvalue"...}
y.setCondition(Instructor_condition,'a0rU0000000PK85IAG')
undefined
y.setCondition(Instructor_condition,'a0rU0000000PK85IAG',true)
undefined
y.updateData()
Object {state: function, always: function, then: function, promise: function, pipe: function...}
y
K {updateable: true, type: "", soql: "SELECT Payroll_Day_Date__c,Name,MMA_Payroll_Period...MMA_Instructor__c = 'a0rU0000000PK85IAG') LIMIT 2", rTypeFor: null, recordTypeInfos: null...}accessible: trueactions: Array[0]calloutIterator: 1canRetrieveMoreRows: truechanges: ObjectchildRelationships: nullconditionLogic: "1AND2"conditions: Array[2]createRowIfNoneFound: falsecreateable: truedata: Array[1]0: ObjectId: "a9NU00000008OKQMA2"Id15: "a9NU00000008OKQ"MMA_Instructor__c: "a0rU0000000PK85IAG"MMA_Instructor__r: ObjectMMA_Payroll_Period__c: "a8ZU00000004CXyMAM"MMA_Payroll_Period__r: ObjectName: "2014-08-01 - Anna"Payroll_Day_Date__c: "2014-08-01"attributes: Object__proto__: Objectlength: 1__proto__: Array[0]dataMap: Objectdebug: ""deleteable: truedoClone: falsedoQuery: trueevents: Objectfields: Array[7]fieldsMap: ObjectforView: nullgroupByFields: nullgroupByMethod: nullhasChanged: falsehavingLogic: nullhavings: nullid: "MMA_Payroll_Period_Instructor_Day"isAggregate: falseisCustom: trueisCustomSetting: falseisFeedEnabled: falseisProcessing: 0isQueryable: trueisSearchable: truekeyPrefix: "a9N"label: "MMA Payroll Period Instructor Day"labelPlural: "MMA Payroll Period Instructor Days"lastSuccessfulCallout: 1lastSyncTime: "2015-03-30T17:20:11.040Z"objectName: "MMA_Payroll_Period_Instructor_Day__c"orderByClause: ""originals: ObjectqueryAllRows: nullrTypeFor: nullreadonly: falserecordTypeInfos: nullrecordsLimit: 1registeredEditors: ObjectregisteredFields: ObjectregisteredFieldsByRowThenField: ObjectregisteredItems: ObjectregisteredItemsByRow: ObjectregisteredLists: Objectsoql: "SELECT Payroll_Day_Date__c,Name,MMA_Payroll_Period__c,MMA_Payroll_Period__r.Name,MMA_Instructor__c,MMA_Instructor__r.Name,Id FROM MMA_Payroll_Period_Instructor_Day__c WHERE (MMA_Instructor__c = 'a0rU0000000PK85IAG') LIMIT 2"type: ""updateable: true__proto__: K
date_condition = y.getConditionByName('Lesson_Date__c')
false
y.setCondition(date_condition,'2015-01-02',true)
undefined
y.updateData
skuid__SkuidJS:25 function (a){return l([this],a)}
y
K {updateable: true, type: "", soql: "SELECT Payroll_Day_Date__c,Name,MMA_Payroll_Period...MMA_Instructor__c = 'a0rU0000000PK85IAG') LIMIT 2", rTypeFor: null, recordTypeInfos: null...}accessible: trueactions: Array[0]calloutIterator: 1canRetrieveMoreRows: truechanges: ObjectchildRelationships: nullconditionLogic: "1AND2"conditions: Array[2]0: ObjectcustomCookie: nullencloseValueInParens: nullencloseValueInQuotes: falsefield: "Payroll_Day_Date__c"fieldTargetObjects: nullfieldfunction: nullformat: nullinactive: truejoinField: nulljoinObject: nulllabel: ""mergeField: nullmergeValue: nullmodel: nullname: "Payroll_Day_Date__c"noValueBehavior: nulloperator: "="originalInactive: trueoriginalValue: ""row: 0subConditionLogic: nullsubConditions: Array[0]length: 0__proto__: Array[0]type: "fieldvalue"units: nullvalue: ""valueTemplate: nullvalues: null__proto__: Object1: ObjectcustomCookie: nullencloseValueInParens: nullencloseValueInQuotes: truefield: "MMA_Instructor__c"fieldTargetObjects: nullfieldfunction: nullformat: nullinactive: falsejoinField: nulljoinObject: nulllabel: ""mergeField: nullmergeValue: nullmodel: nullname: "MMA_Instructor__c"noValueBehavior: nulloperator: "="originalInactive: trueoriginalValue: ""row: 0subConditionLogic: nullsubConditions: Array[0]type: "fieldvalue"units: nullvalue: "a0rU0000000PK85IAG"valueTemplate: nullvalues: null__proto__: Objectlength: 2__proto__: Array[0]createRowIfNoneFound: falsecreateable: truedata: Array[1]0: ObjectId: "a9NU00000008OKQMA2"Id15: "a9NU00000008OKQ"MMA_Instructor__c: "a0rU0000000PK85IAG"MMA_Instructor__r: ObjectMMA_Payroll_Period__c: "a8ZU00000004CXyMAM"MMA_Payroll_Period__r: ObjectName: "2014-08-01 - Anna"Payroll_Day_Date__c: "2014-08-01"attributes: Object__proto__: Objectlength: 1__proto__: Array[0]dataMap: Objectdebug: ""deleteable: truedoClone: falsedoQuery: trueevents: Objectfields: Array[7]fieldsMap: ObjectforView: nullgroupByFields: nullgroupByMethod: nullhasChanged: falsehavingLogic: nullhavings: nullid: "MMA_Payroll_Period_Instructor_Day"isAggregate: falseisCustom: trueisCustomSetting: falseisFeedEnabled: falseisProcessing: 0isQueryable: trueisSearchable: truekeyPrefix: "a9N"label: "MMA Payroll Period Instructor Day"labelPlural: "MMA Payroll Period Instructor Days"lastSuccessfulCallout: 1lastSyncTime: "2015-03-30T17:20:11.040Z"objectName: "MMA_Payroll_Period_Instructor_Day__c"orderByClause: ""originals: ObjectqueryAllRows: nullrTypeFor: nullreadonly: falserecordTypeInfos: nullrecordsLimit: 1registeredEditors: ObjectregisteredFields: ObjectregisteredFieldsByRowThenField: ObjectregisteredItems: ObjectregisteredItemsByRow: ObjectregisteredLists: Objectsoql: "SELECT Payroll_Day_Date__c,Name,MMA_Payroll_Period__c,MMA_Payroll_Period__r.Name,MMA_Instructor__c,MMA_Instructor__r.Name,Id FROM MMA_Payroll_Period_Instructor_Day__c WHERE (MMA_Instructor__c = 'a0rU0000000PK85IAG') LIMIT 2"type: ""updateable: true__proto__: K
date_condition = y.getConditionByName('Payroll_Day_Date__c')

Object {valueTemplate: null, values: null, value: "", units: null, type: "fieldvalue"...}
y.setCondition(date_condition,'2015-01-02',true)
undefined
y.updateData
skuid__SkuidJS:25 function (a){return l([this],a)}
y
K {updateable: true, type: "", soql: "SELECT Payroll_Day_Date__c,Name,MMA_Payroll_Period...MMA_Instructor__c = 'a0rU0000000PK85IAG') LIMIT 2", rTypeFor: null, recordTypeInfos: null...}accessible: trueactions: Array[0]calloutIterator: 1canRetrieveMoreRows: truechanges: ObjectchildRelationships: nullconditionLogic: "1AND2"conditions: Array[2]0: ObjectcustomCookie: nullencloseValueInParens: nullencloseValueInQuotes: falsefield: "Payroll_Day_Date__c"fieldTargetObjects: nullfieldfunction: nullformat: nullinactive: falsejoinField: nulljoinObject: nulllabel: ""mergeField: nullmergeValue: nullmodel: nullname: "Payroll_Day_Date__c"noValueBehavior: nulloperator: "="originalInactive: trueoriginalValue: ""row: 0subConditionLogic: nullsubConditions: Array[0]type: "fieldvalue"units: nullvalue: "2015-01-02"valueTemplate: nullvalues: null__proto__: Object1: Objectlength: 2__proto__: Array[0]createRowIfNoneFound: falsecreateable: truedata: Array[1]0: ObjectId: "a9NU00000008OKQMA2"Id15: "a9NU00000008OKQ"MMA_Instructor__c: "a0rU0000000PK85IAG"MMA_Instructor__r: ObjectMMA_Payroll_Period__c: "a8ZU00000004CXyMAM"MMA_Payroll_Period__r: ObjectName: "2014-08-01 - Anna"Payroll_Day_Date__c: "2014-08-01"attributes: Object__proto__: Objectlength: 1__proto__: Array[0]dataMap: Objectdebug: ""deleteable: truedoClone: falsedoQuery: trueevents: Objectfields: Array[7]fieldsMap: ObjectforView: nullgroupByFields: nullgroupByMethod: nullhasChanged: falsehavingLogic: nullhavings: nullid: "MMA_Payroll_Period_Instructor_Day"isAggregate: falseisCustom: trueisCustomSetting: falseisFeedEnabled: falseisProcessing: 0isQueryable: trueisSearchable: truekeyPrefix: "a9N"label: "MMA Payroll Period Instructor Day"labelPlural: "MMA Payroll Period Instructor Days"lastSuccessfulCallout: 1lastSyncTime: "2015-03-30T17:20:11.040Z"objectName: "MMA_Payroll_Period_Instructor_Day__c"orderByClause: ""originals: ObjectqueryAllRows: nullrTypeFor: nullreadonly: falserecordTypeInfos: nullrecordsLimit: 1registeredEditors: ObjectregisteredFields: ObjectregisteredFieldsByRowThenField: ObjectregisteredItems: ObjectregisteredItemsByRow: ObjectregisteredLists: Objectsoql: "SELECT Payroll_Day_Date__c,Name,MMA_Payroll_Period__c,MMA_Payroll_Period__r.Name,MMA_Instructor__c,MMA_Instructor__r.Name,Id FROM MMA_Payroll_Period_Instructor_Day__c WHERE (MMA_Instructor__c = 'a0rU0000000PK85IAG') LIMIT 2"type: ""updateable: true__proto__: K
Photo of Anna Orias

Anna Orias

  • 136 Points 100 badge 2x thumb

Posted 4 years ago

  • 1
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
A quick check: has the model been re-queried after the conditions were applied?
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Anna,

Here is Zach's reply. It accidentally ended up on the wrong thread.

Anna, it looks like you may not have actually called updateData after setting your two date conditions? It looks like you just entered updateData but did not use parentheses, so the Model was never actually updated --- you need to call updateData() again as you did earlier in order to actually make the Model go request new data from Salesforce in light of the altered Conditions.
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
Thanks Matt - not sure how that happened...