I have an object (table) that I want to populate with a set of template rows that will be stored in another object (table).
The skuid Action framework includes Adopt Rows Into Model, but I don’t find any documentation for it. The adoptRow() javascript function may provide background, but its definition refers to external data. It also talks about matching on Id’s.
Let me sketch this out a bit:
TARGET OBJECT
RecId Name Level Group Factor Data6 Data7 ...<br>----- ---- ----- ----- ------ ----- ----- ...
SOURCE OBJECT
RecId Name Level Group Factor Condition1 Condition2<br>ab001 1234 1 A Red Thursday Dent<br>ab002 1235 1 A Blue Thursday Dent<br>ab003 1236 2 A Yellow Thursday Dent<br>ab004 1237 1 A Red Monday Dent<br>ab005 1238 2 B White Monday Dent<br>ab006 1239 1 A Blue Monday Prefect<br>ab007 1240 2 B Green Thursday Prefect
I would have a model based on the Source object, with conditions for selecting by day and by person. I will query the model. If the condition values are Monday and Dent, the model will contain 2 rows: Level 1, Group A, Factor Red; and Level 2, Group B, Factor White.
I want to copy these 2 rows into my Target model, as…
RecId Name Level Group Factor Data6 Data7 ...<br>ar01a 2468 1 A Red ----- ----- ...<br>ar01b 2469 2 B White ----- ----- ...
Use Case: Create an evaluation matrix from a template. There will be a separate matrix for each client. Based on criteria in the Client object, one of several templates will be used to initialize the matrix.
Re. 1 The source object contains multiple templates. Each template consists of multiple records. Certain fields in the source (template) object identify the template criteria and match the criteria fields in the Client object. Other fields in the source/template match the fields in the Evaluation (target) object. There are also some fields in the source object that are used for template maintenance. These are not used for selection criteria or copied to the target. (These also include the standard fields like createddate, name, id, etc.)
Re. 2 The page will have a Page Title component with a button for “Create Matrix”. It is rendered if the Evaluation (target) model has no data rows. (The Evaluation model includes a condition for a single Client Id.) The Create Matrix button actions will:
Activate and set condition on the Template model
Query the template model
Copy the rows from the Template model into the Evaluation model
The action framework would allow creation of new rows in the Evaluation model and set default values according to a template, but then the template definition is embedded in the skuid actions. Changing a template rows and values would require changing the page. Pulling the rows in from a separate object allows the templates to be maintained independent of their use.
Ok. You should be able to adopt the rows into the target so long as you have fields with the same name in the target. Worst case is you have to create UI only fields with the same metadata settings in order for the rows/fields from the Source Target to display properly. Should be no problem.
How do you intend to adopt the rows? Once the Source table is queried, you can use a Row, Mass or Global Action w/ Action Framework to do this.
Adopt Rows works nicely - to a point. It apparently copies those fields with matching names (and meta-data?) from the source model to the target model. However, this also includes the standard Id field. Since the source and target models are different objects, the a2xr… Id’s from the source generate an “Invalid Id for Evaluation__c” error. The Evaluation Id is a2kr…
Apparently the Adopt Rows action expects the source and target models to use the same sObject. And, the target model will be using the SAME ROWS from that object.
Apparently, I will need to use javascript to copy from a template object to a target.
I had enough of the javascript built that I went ahead with that method in the interest of time. I have not been back (yet) to load and evaluate Pat’s test page. You might try that if you have the time, and I could also share my javascript. I do wish there was documentation of the Adopt Rows action.
I hope this helps! The following is an Inline Snippet. It is called from a button action on a Page Title component.
// Get the Template and new Matrix models. var template = skuid.model.getModel(‘CasePlanTemplateRows’); var matrix = skuid.model.getModel(‘CasePlanLevelFactors’);
// Walk the array of Template rows var templateRows = template.getRows(); for ( i=0; i < templateRows.length; i++) { // Get the template values from each row, one row at a time var templateRow = templateRows[i]; var templateSequence = template.getFieldValue( templateRow, ‘Row_Sequence__c’); var templateGroup = template.getFieldValue( templateRow, ‘Factor_Group__c’); var templateFactor1 = template.getFieldValue( templateRow, ‘Level_1_Factor__c’);
// Create a new matrix row; copy the template-row values into it var matrixRow = matrix.createRow( {doAppend:true} ); matrix.updateRow( matrixRow, { Row_Sequence__c: templateSequence, Factor_Group__c: templateGroup, Level_1_Factor__c: templateFactor1 }) }