save of new rows fails with references to other new rows in same model

  • 1
  • Problem
  • Updated 1 year ago
  • In Progress
I am creating several rows in a model, some of which have internal reference fields. Save fails with "invalid reference field" error.

Example:
These new rows exist in the model:
Row 1: {Id: 'new1', Parent__c: ''}
Row 2: {Id: 'new2', Parent__c: 'new1'},
Row 3: {Id: 'new3', Parent__c: 'new1'},
Row 4: {Id: 'new4', Parent__c: 'new3'}

After save, Row 1 is saved, all the others fail to save.

Skuid is somehow not processing/adjusting the internal reference fields during the save?
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb

Posted 1 year ago

  • 1
Photo of Stephen Sells

Stephen Sells, Official Rep

  • 16,856 Points 10k badge 2x thumb
How are you attempting to accomplish this? Can you share your configuration using only standard objects and fields?
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Sorry for my ignorance: Are there self-referencing standard objects? And by that I mean, is there a standard object with a reference field that looks up to itself?
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Regardless of how i've gnerated it, I've pasted below a JSON string representing nested objects. in object form, this is the value of 'menuOrder' in the javascirpt below.

Here's the javascript that's generating the new rows:

var pRow, sRow;
$.each(menuOrder,function(i,p){
            if (i) pRow = model.createRow({
             doAppend:true,
             additionalConditions:[
                 {field: 'Item__c', value: p.Item__c},
                 {field: 'Order__c', value: i},
                 {field: 'Parent_Menu__c', value: ''},
                 {field: 'Staff__c', value: staff}
             ]
         });
            $.each(p.kids,function(i,s){
             if (i) sRow = model.createRow({
                 doAppend:true,
                 additionalConditions:[
                     {field: 'Item__c', value: s.Item__c},
                     {field: 'Order__c', value: i},
                     {field: 'Parent_Menu__c', value: pRow.Id},
                     {field: 'Staff__c', value: staff}
                 ]
             });
             $.each(s.kids,function(i,t){
                 if (i) model.createRow({
                     doAppend:true,
                     additionalConditions:[
                         {field: 'Item__c', value: t.Item__c},
                         {field: 'Order__c', value: i},
                         {field: 'Parent_Menu__c', value: sRow.Id},
                         {field: 'Staff__c', value: staff}
                     ]
                 });
             });
            });
        });

menuOrder is an object, an example of which I've converted to JSON sand pasted here, which you're welcome to parse for testing purposes. This isn't standard SFDC objects, but perhaps looking at this will make sense out of the problem?

{"1":{"Item__c":"a1F41000002P2TaEAK","Id":"a1J41000009o7SmEAI","kids":{"1":{"Item__c":"a1F41000002P2TkEAK","Id":"a1J41000009o7WKEAY","kids":{}},"2":{"Item__c":"a1F41000002P2TfEAK","Id":"a1J41000009o7WPEAY","kids":{}},"3":{"Item__c":"a1F41000002P2c0EAC","Id":"a1J41000009o8pFEAQ","kids":{}},"4":{"Item__c":"a1F41000002P2dIEAS","Id":"a1J41000009o8zkEAA","kids":{}},"5":{"Item__c":"a1F41000002P2dNEAS","Id":"a1J41000009o8zuEAA","kids":{}},"6":{"Item__c":"a1F41000002P2dXEAS","Id":"a1J41000009oCQaEAM","kids":{}}}},"2":{"Item__c":"a1F41000002P2dcEAC","Id":"a1J41000009oCQQEA2","kids":{"1":{"Item__c":"a1F41000002P2dmEAC","Id":"a1J41000009o90OEAQ","kids":{}},"2":{"Item__c":"a1F41000002P2dhEAC","Id":"a1J41000009o90EEAQ","kids":{}},"3":{"Item__c":"a1F41000002P2dwEAC","Id":"a1J41000009o90dEAA","kids":{}}}},"3":{"Item__c":"a1F41000002P2e1EAC","Id":"a1J41000009o90iEAA","kids":{"1":{"Item__c":"a1F41000002P2e6EAC","Id":"a1J41000009oCQeEAM","kids":{}},"2":{"Item__c":"a1F41000002P2eBEAS","Id":"a1J41000009oCQfEAM","kids":{}},"3":{"Item__c":"a1F41000002P2eGEAS","Id":"a1J41000009oCQgEAM","kids":{}},"4":{"Item__c":"a1F41000002P2eLEAS","Id":"a1J41000009o917EAA","kids":{"1":{"Item__c":"a1F41000002P2eQEAS","Id":"a1J41000009o91gEAA","kids":{}},"2":{"Item__c":"a1F41000002P2eaEAC","Id":"a1J41000009o92AEAQ","kids":{}}}},"5":{"Item__c":"a1F41000002P2ekEAC","Id":"a1J41000009o938EAA","kids":{}},"6":{"Item__c":"a1F41000002P2epEAC","Id":"a1J41000009o93IEAQ","kids":{}},"7":{"Item__c":"a1F41000002P2euEAC","Id":"a1J41000009o93NEAQ","kids":{}}}},"4":{"Item__c":"a1F41000002P2ezEAC","Id":"a1J41000009oCQSEA2","kids":{"1":{"Item__c":"a1F41000002P2f9EAC","Id":"a1J41000009o93mEAA","kids":{}},"2":{"Item__c":"a1F41000002P2f4EAC","Id":"a1J41000009o93cEAA","kids":{}},"3":{"Item__c":"a1F41000002P2fEEAS","Id":"a1J41000009o93rEAA","kids":{}}}},"5":{"Item__c":"a1F41000002P2fJEAS","Id":"a1J41000009o946EAA","kids":{"1":{"Item__c":"a1F41000002P2fOEAS","Id":"a1J41000009o94BEAQ","kids":{}},"2":{"Item__c":"a1F41000002P2fTEAS","Id":"a1J41000009o94LEAQ","kids":{}},"3":{"Item__c":"a1F41000002P2fYEAS","Id":"a1J41000009o94QEAQ","kids":{}},"4":{"Item__c":"a1F41000002P2fdEAC","Id":"a1J41000009o94VEAQ","kids":{}}}},"6":{"Item__c":"a1F41000002P2fiEAC","Id":"a1J41000009o95JEAQ","kids":{"1":{"Item__c":"a1F41000002P2fnEAC","Id":"a1J41000009o95YEAQ","kids":{}},"2":{"Item__c":"a1F41000002P2fsEAC","Id":"a1J41000009o95dEAA","kids":{}},"3":{"Item__c":"a1F41000002P2fxEAC","Id":"a1J41000009o95nEAA","kids":{}},"4":{"Item__c":"a1F41000002P2gbEAC","Id":"a1J41000009oCQvEAM","kids":{"1":{"Item__c":"a1F41000002P2ggEAC","Id":"a1J41000009oCR2EAM","kids":{}},"2":{"Item__c":"a1F41000002P2glEAC","Id":"a1J41000009oCR3EAM","kids":{}},"3":{"Item__c":"a1F41000002P2gqEAC","Id":"a1J41000009oCR4EAM","kids":{}}}},"5":{"Item__c":"a1F41000002P2gvEAC","Id":"a1J41000009oCQwEAM","kids":{"1":{"Item__c":"a1F41000002P2h0EAC","Id":"a1J41000009oCR5EAM","kids":{}},"2":{"Item__c":"a1F41000002P2hAEAS","Id":"a1J41000009oCR6EAM","kids":{}},"3":{"Item__c":"a1F41000002P2hFEAS","Id":"a1J41000009oCR7EAM","kids":{}},"4":{"Item__c":"a1F41000002P2hPEAS","Id":"a1J41000009oCR8EAM","kids":{}}}},"6":{"Item__c":"a1F41000002P2hUEAS","Id":"a1J41000009oCQxEAM","kids":{"1":{"Item__c":"a1F41000002P2hZEAS","Id":"a1J41000009oCR9EAM","kids":{}},"2":{"Item__c":"a1F41000002P2heEAC","Id":"a1J41000009oCRAEA2","kids":{}},"3":{"Item__c":"a1F41000002P2hjEAC","Id":"a1J41000009oCRBEA2","kids":{}},"4":{"Item__c":"a1F41000002P2hoEAC","Id":"a1J41000009oCRCEA2","kids":{}},"5":{"Item__c":"a1F41000002P2hyEAC","Id":"a1J41000009oCRDEA2","kids":{}},"6":{"Item__c":"a1F41000002P2i3EAC","Id":"a1J41000009oCREEA2","kids":{}},"7":{"Item__c":"a1F41000002P2htEAC","Id":"a1J41000009oCRFEA2","kids":{}}}},"7":{"Item__c":"a1F41000002P2i8EAC","Id":"a1J41000009oCQyEAM","kids":{"1":{"Item__c":"a1F41000002P2iDEAS","Id":"a1J41000009oCRGEA2","kids":{}},"2":{"Item__c":"a1F41000002P2iIEAS","Id":"a1J41000009oCRHEA2","kids":{}},"3":{"Item__c":"a1F41000002P2iNEAS","Id":"a1J41000009oCRIEA2","kids":{}},"4":{"Item__c":"a1F41000002P2iSEAS","Id":"a1J41000009oCRJEA2","kids":{}},"5":{"Item__c":"a1F41000002P2icEAC","Id":"a1J41000009oCRKEA2","kids":{}},"6":{"Item__c":"a1F41000002P2ihEAC","Id":"a1J41000009oCRLEA2","kids":{}},"7":{"Item__c":"a1F41000002P2imEAC","Id":"a1J41000009oCRMEA2","kids":{}},"8":{"Item__c":"a1F41000002P2irEAC","Id":"a1J41000009oCRNEA2","kids":{}}}},"8":{"Item__c":"a1F41000002P2iwEAC","Id":"a1J41000009o9cBEAQ","kids":{"1":{"Item__c":"a1F41000002P2j1EAC","Id":"a1J41000009o9dOEAQ","kids":{}},"2":{"Item__c":"a1F41000002P2epEAC","Id":"a1J41000009o9cqEAA","kids":{}},"3":{"Item__c":"a1F41000002P2euEAC","Id":"a1J41000009o9cvEAA","kids":{}},"4":{"Item__c":"a1F41000002P2j6EAC","Id":"a1J41000009o9dyEAA","kids":{}},"5":{"Item__c":"a1F41000002P2jBEAS","Id":"a1J41000009o9epEAA","kids":{}},"6":{"Item__c":"a1F41000002P2jGEAS","Id":"a1J41000009o9fbEAA","kids":{}}}}}}}"