Mass Create Records

This tutorial shows you how to mass create records in Salesforce using Skuid. Learn how to have a (1) Mass Create action that will take you to (2) a mass create wizard where you can specify default information and (3) mass generate records for every contact associated with the account and then edit and save these records.

image0

Note

In this example we’ll be dealing with a custom object called “Statements” that is associated with an Account, a Contact and an Amount, but you can follow these instructions using any standard or custom object.

Step 1: Click Create New Page.

image1

Name your New Page and click Create Page.

image2

Step 2: Add a model to correspond to your parent object.

image3

A. Set your model to the proper object and then click to add a Condition.

image4

B. Add a condition so that this model will only pull in 1 record, whose ID is in the URL.

image5

  1. For field, select the Record ID field.
  2. Click Value.
  3. Choose URL parameter as the Content.
  4. Enter the url parameter name. This will be a URL parameter you create and will reference at different steps in this process. It can be called anything you want, for example Cheese. It does, however, make sense to have it somehow related to your parent object’s name, or something you can standardize across your org. We use accid.

C. Include the ID and Name fields in this model.

image6

Step 3: Drag a Page Title into this page.

image7

A. Title this page.

image8

You can include fields from this model in your page title. For example, the {{Name}} template will pull in the Name field for the page record :)

B. Delete all page title actions.

image9

Step 4: Drag a Wizard below your page title.

image10

Step 5: Create a model to provide the template for the records to be mass created.

image11

A. Format the model properties.

image12

  1. Name your model.
  2. Set this model to the object type that you want to mass create records for.
  3. Click the Advanced tab.
  4. For “Max # of records”, enter 1.
  5. Check Create Default Row if Model Has None.
  6. Uncheck “Query on page load.”

This will ensure that this model will create a brand new statement. Later, we’ll copy-paste-tweak some JavaScript that will take the information from this model and use it to mass create records.

B. In this model, only add the fields that you want to be auto-populated in the mass create.

image13

We’ll just choose “Amount” and “Date.”

Step 6: Create a model for the records that will be mass created.

image14

A. Format the model properties.

image15

  1. Name this model.
  2. Set it to the object type that you want to mass create records for.
  3. Click Advanced.
  4. Make everything blank and unchecked here. This will ensure that your page loads faster and that it doesn’t bring any previously created records.

B. In this model, add every field that you want to be autopopulated and/or edited in the mass create process.

image16

Step 7: Add conditions on this model.

image17

The Javascript we’ll add to this page will “read” these conditions and use them to autopopulate information in the mass created records. Pretty cool, right?

For every field you want to be autopopulated in the mass create process, create a filterable condition.

image18

We want the Date and Amount fields to be autopopulated, so we’ll add conditions for these two fields.

  1. Set the condition to the field you want autopopulated.
  2. Click State.
  3. Choose Filterable default off as the state. Don’t worry about operator, value, or any other property.
  4. Name this condition something simple. You’ll be using this name in the Javascript snippet later.

Step 9: Important: Enter the Mass Create Custom Javascript.

image24

A. Choose “Inline (Snippet)” as the Resource Location, and name this snippet. Then click to add the Body.

image25

B. Copy and paste this code into the editor and then revise the following generic examples to match your own models, conditions, and fields.

image26

// Copy and paste the code below into the code editor. Everything in bold is something specific to our example, that you should substitute with your own Variable names, Model names, Condition names, and Field names.

// Everything preceded by these two slashes is a helpful note to guide you on your journey.

var params = arguments[0];
var step = params.step;
var $ = skuid.$;
// Get references to our three important Models
var models = skuid.model.map();
var contacts = models.Contacts;
var protoStatement = models.ProtoStatement;
var newStatements = models.NewStatements;
// Use the values specified in our protoStatement record
// to set conditions on our newStatements model.
// That way, when we auto-generate new statement records,
// these conditions will be used to prepopulate each new Statement.
var proto = protoStatement.getFirstRow();
var dateCondition = newStatements.getConditionByName('date');
var amountCondition = newStatements.getConditionByName('amount');
newStatements.setCondition(dateCondition,protoStatement.getFieldValue(proto,'Date__c'));
newStatements.setCondition(amountCondition,protoStatement.getFieldValue(proto,'Amount__c'));
// Now, auto-generate a new Statement record
// for each Contact in this Account.
$.each(contacts.data,function(){
 \   var row = newStatements.createRow({
       additionalConditions: [
           { field: 'Contact__c', value: this.Id, operator: '=', nameFieldValue: this.Name }
       ]
   });
});
// We're good to go - navigate our wizard to Step 2
step.navigate('step2');

Update to your own parameters:

  • contacts
  • protoStatement
  • newStatements
  • dateCondition
  • date
  • Date__c
  • amountCondition
  • amount
  • Amount__c
  • Contact__c

C. You’ve worked hard. Don’t lose it all. Click Save.

image27

Now we can start actually building the Wizard :) This is much simpler.

Step 10: Drag and drop in a field editor to set the defaults for the records that will be mass created.

image28

A. Configure field editor properties.

image29

  1. Set the field editor model to ProtoStatement - your template model.
  2. Choose Edit as the Default Mode. This will lock fields in edit mode.

B. Drag the desired fields into your Field Editor.

image30

  1. Drag the fields into the field editor that you want to autopopulate in the mass created records.
  2. Adjust the field editor as desired. Click on the top of a column to remove that column, adjust its width, or add a section to that column. Click on a section title to rename it. Click on the field editor to add columns.

Step 11: Add actions to Step 1.

image31

  1. Click on the Wizard.
  2. Click Add New Step.
  3. Click on Step 1.
  4. Now, you will have the option to Add an Action. Click to add 2 actions.

A. Make the first action a “Return to Account” button.

image32

  1. Click on the action on the left - this is the logical place for a cancel/return button.
  2. Choose Navigate as the type.
  3. Name your button something helpful, e.g. Return to Account.
  4. Add a helpful icon - like ui-silk-arrow-turn-left.
  5. Enter the redirect URL - /{{Param.accid}} will take you back to the Account View page. (Make sure you enter your own URL parameter created in Step 2.)

B. Make the second action your Generate/Mass Create Button.

image33

This button will execute our snippet and mass generate the records. The snippet also tells the Wizard to navigate to the next step :D

  1. Click on the other button.
  2. Choose Custom as the action type.
  3. Name your button something helpful, i.e. Generate Statements.
  4. Choose an appropriate button icon, e.g. ui-silk-application-cascade.
  5. Enter the name of the snippet that you created in Step 9.

Step 12: In the second step add a table to display the mass generated records.

image34

  1. Click to open Step 2.
  2. Drag in a table to display the mass generated records. This table will allow users to tweak the mass created records before they save them.
  3. Set this table to the NewStatements model.
  4. Again, you can choose Edit as the default mode so that the records will appear instantly open for editing (without having to click).
  5. Unclick “Show Save/Cancel.” We’ll create a final Save button on the Wizard.

Include any fields that you want to be editable on the mass generated records.

image35

Note

The fields that you want to carry over from your template model (ProtoStatements) must be included in the NewStatements model to be populated in the mass created records. You don’t have to include these fields on your table, but you can include them if you want users to be able to tweak them before saving. In this table you can also include other fields that you want users to be able to populate before saving the mass generated records.

Step 13: Add Cancel and Save buttons on Step 2.

image36

  1. Click on Step 2.
  2. Click to Add two actions.

A. Make the left action a Cancel and Return button.

image37

This action will allow users to navigate to the previous step and cancel any changes they’ve made on the NewStatements model.

  1. Click on the action button.
  2. Choose Cancel as the type.
  3. Name your button something useful, e.g. Previous Step.
  4. Add a helpful icon, e.g. ui-silk-arrow-left.
  5. Choose which models you want to cancel here - this should be the model managing your new records, e.g. NewStatements.
  6. For Step Id, enter step1 e.g. the name of the step you want this button to take the user to. (You can change Step ID by clicking on that step.)

B. Make the second action a Save and Finish button.

image38

  1. Click on the other action.
  2. Choose Save as the action type.
  3. Name the button, e.g. Save Statements and Finish.
  4. Choose a helpful icon, e.g. ui-silk-accept.
  5. Choose which model to Save - your new records (e.g. NewStatements) model.
  6. Enter a Redirect URL to take users to when they finish - we’ll take them back to the Account page by using /{{$Param.accid}}. Remember, “accid” is the parameter you create and name on your own in Step 2.

Step 14: Click Save.

image39

Step 16: Test it!

Click on your “Mass Create” button…

image44

If this button doesn’t work, make sure that you entered the correct Redirect URL in Step 15. Make sure that the name of your own Mass Create Page appears in the URL after page=.

If this is the case and it still doesn’t work, Preview your Mass Create Wizard page. Copy and paste everything in the URL after force.com as the Redirect URL. Remember to add accid={{$Param.id}} at the end (where accid is the parameter you created in step 2) so that the mass generated records will be associated with the parent object record.

A. You will be directed to your new Mass Create Wizard…

image45

  1. Enter the default values for the records to be mass created. (The red highlighting means that these fields are required, either by this Skuid page or in your SF data model.)
  2. Click on your “Mass Generate” button.

Problems with this page? For field editor issues, see Step 10. For button issues, see Step 11. Make sure you entered the proper name for your generateStatements snippet.

B. A list of mass generated statements will appear. Tweak and click Save & Finish.

image46

If this list doesn’t appear, double check the snippet (Step 9). Make sure that in the snippet you inserted your own personal variable, model, condition and field names!

  1. In this table you can add, edit, or delete records. Note than any records you add will be autopopulated with the fields you specified in Step 1 of the Wizard (e.g. Date and Amount).
  2. Click Save and Finish.

C. Success! Your mass created records will be displayed

image47

Troubleshooting

image48

Having problems?

  • Check out the Troubleshooting tips in 16.1-3.
  • Go back over these steps and make sure that you didn’t miss anything.

Still having problems? You can ask questions, browse answers, and report problems at community.skuid.com.

  • You may not have noticed, but the Skuid page builder has a View/Edit XML link at the bottom lefthand corner that’s active after you saved. This is a great way to <!– comment out parts of the page that you think might be causing problems –>
  • Select all of the XML and copy and paste it into your email. You can also wrap it in <pre><code></code></pre> HTML to share it on the community. This will help us solve your problem faster.