In This Section
- Concepts
- Data
- Build
- The Composer
- Context
- Pages
- Models
- Components
- Best Practices
- Debugging Skuid in the Console
- Logic
- Style
- Deploy
- Extend
- Reference
- API Reference
- skuid.$
- skuid.actions
- skuid.ajax
- skuid.builder.core
- skuid.builder.core.coreProps
- skuid.calendar
- skuid.collaboration
- skuid.component
- skuid.componentType
- skuid.events
- skuid.formula
- skuid.hotkeys
- skuid.label
- skuid.lightning
- skuid.load
- skuid.model
- skuid.model.Model
- skuid.mustache
- skuid.page
- skuid.sfdc
- skuid.snippet
- skuid.time
- skuid.ui
- skuid.utils
- skuid.version
- Component-Specific APIs
- Skuid Model Metadata Object
- Skuid Model Child Relationship Metadata Object
- Skuid Model Condition Metadata Object
- Skuid Model Field Metadata Object
- Skuid Model Record Type Metadata Object
- Page XML API
- skuid-sfdx
- Skuid Metadata Object Reference
- Skuid Glossary
- Formula and Function Reference
- Skuid and Date/Time
- Open Source Software Attributions
- API Reference
- Site Administration
- Tutorials
- Skuid Page Tutorials
- Add Related Lists with the Table Component
- Build an Activities Related List Tab
- Build a Custom “Create New Record” Page
- Build a Custom Detail Page
- Build a Custom List Page
- Compose a Branded Header and Navigation
- Compose a One-Page App Using Tab Actions and Conditional Rendering
- Conditionally Display Fields
- Create a Custom Clone Page
- Create a Custom “Clone Account” page
- Highlight Critical Data: Wrappers, Rich Text, and Ui-Only Fields
- Mass Create Records
- Show Products in an Opportunity Page
- Skuid Pages for standard Salesforce CRM
- Salesforce Tutorials
- JavaScript Tutorials
- Skuid Page Tutorials
- Legal terms and conditions
- Skuid SFX Evaluation Guide
In This Topic
- Build an Activities Related List Tab
- Goal: Build this Activities tab.
- Step 1: Build an Opportunity Detail Page and include a tab set component to organize your related lists.
- Step 2: Add the Activities tab.
- Step 3: Add another Tab Set.
- Step 4: Add the Tasks tab.
- Step 5: Create a Model for Open Tasks.
- Step 6: Add Conditions that will only include Open Tasks in this Model.
- Step 7: Add a new Model for Closed Tasks.
- Step 8: Create Conditions that will only include Closed Tasks in this Model.
- Step 9: Create headings for your Open Tasks and Closed Tasks sections.
- Step 10: Add Tables to the Tasks tab.
- Step 11: Include the Javascript snippet to “Mark Tasks Completed”
- Copy and paste this snippet to Mark Tasks Completed.
- Click on your Open Tasks table and click Add Features, then Add Row Action.
- Make the row action a custom action called Mark Completed.
- Still in the Open Tasks Table, create a mass Mark Completed action.
- Click on the Completed Tasks Table and edit its properties.
- Step 12: Create row Popup to “View Task Details”
- Step 13: Click Add Features > Add Global Actions.
- Step 14: Add another tab to the Activities Tab Set.
- Step 15: Drag and drop a Calendar into this tab.
- Step 16: Click to Add an Event Source.
- Step 17: Click to Add a second Event Source to this Calendar.
- Step 18: Click Save, then click Preview.
- Success! Your Activities tab will be displayed.
- Troubleshooting
Build an Activities Related List Tab¶
This Activities tab is a solid addition to any Opportunity “View” page.
Goal: Build this Activities tab.¶
- The finished Activities tab will have lists of Open and Completed Tasks, and a calendar showing related events.
- You will be able to add and edit tasks inline.
- We’ll create actions to mark a task completed, view the full conversation, log an email, and log a call.
Step 1: Build an Opportunity Detail Page and include a tab set component to organize your related lists.¶
To build an Activities tab like this one, you first need a Detail Page. We suggest you use the tab set component to organize your related lists.
Step 2: Add the Activities tab.¶
We’re going to add a tab for the Activities Related Lists (Open Activities and Activity History).
- Click on the Tab Set component within your Skuid page.
- Click the Add Tab button.
- Click on the New Tab in the Tab Set component.
- Type in a name for the tab. In this case, let’s use Activities.
- Optional: select an icon for the tab. Here we’ve chosen the sk-icon-phone icon. Click on the icon picker for a huge selection of icons.
Step 4: Add the Tasks tab.¶
- Click on the New Tab in the nest Tab Set component.
- Type in a name. In this case, let’s use Tasks for the tab name.
- Optional: select an icon for the tab. Here we’ve chosen the ui-silk-tick icon. Click on the icon picker for a huge selection of icons.
Step 5: Create a Model for Open Tasks.¶
- Click on the Models tab.
- Click Add Model.
- Type in OpenTasks for the Model Id.
- Select the Task object for the SObject Type.
- Click on the Advanced tab.
- Order the records by ActivityDate DESC. This will display the Open Task records with the newest at the top of the list and oldest at the bottom.
Step 6: Add Conditions that will only include Open Tasks in this Model.¶
- Click on the Models tab.
- Click on the OpenTasks model you created in Step 5.
- Click on the Add New Condition button. Do this 3 times because we will need to create 3 conditions.
First Condition: WhatId = the id parameter in the page’s url.¶
First, we need to create a condition that will only pull in Tasks that are related to the main Opportunity record on the page.
- Click on the new condition you created in Step 3.
- Click on the field-picker button to bring up the Select Field window.
- Select the WhatId (Opportunity/Account ID) from the Select Field window.
- Click in the Value field.
- Choose URL Parameter as the Content.
- Enter Id as the Parameter.
Second Condition: Status != Completed¶
- Select the 2nd condition under your OpenTasks Model.
- Click on the Field-Picker Button to bring up the Select Fields window. Select the Status field.
- Click on the Operator field. Choose != (is not equal to) from the Operator dropdown menu.
- Click on the Value field.
- Enter Completed as the value.
This Condition will only pull in conditions whose Status is not Completed. Or, stated differently, this Condition will only pull in conditions that are open.
Third Condition: IsClosed != true¶
The third and final condition we’ll create will keep this Model from pulling in tasks that are Closed.
- Selet the third condition you created earlier.
- Click on the Field-Picker button and select IsClosed from the Select Field window.
- Click the Operator field and select != (is not) from the Operator dropdown menu.
- Click the Value field and make sure that the Value checkbox is checked (true). Your condition automatically recognizes that the IsClosed field is checkbox and renders the Value as a corresponding checkbox. Easy and awesome!
Step 7: Add a new Model for Closed Tasks.¶
- Click on the Models tab.
- Click Add Model.
- Name this model TaskHistory.
- Select the Task SObject Type.
- Click on the Advanced tab.
- Order the records by ActivityDate DESC. This will display the Open Task records with the newest at the top of the list and oldest at the bottom.
Step 8: Create Conditions that will only include Closed Tasks in this Model.¶
- Click on the Models tab.
- Click on the TaskHistory model you created in Step 7.
- Click on the Add New Condition button. Do this 2 times because we will need to create 2 conditions.
First Condition: WhatId = the id parameter in the page’s url¶
- Click on the first empty Condition you just created.
- For the Field, use the field-picker to select the WhatId (Opportunity/Account ID).
- Click on the Value field.
- Choose URL Parameter from the Content dropdown menu.
- Enter Id in the Parameter field.
This condition will only pull in Tasks that are associated with the main Opportunity record on the page.
Second Condition: IsClosed=True.¶
This condition will make the Model only pull in Closed Tasks.
- Select the second Condition you created earlier.
- For the Field value, use the field-picker to choose the IsClosed field.
- Click Value and make sure that the checkbox next to Value is checked!
Step 9: Create headings for your Open Tasks and Closed Tasks sections.¶
- Click on the Components tab.
- Drag and drop 2 Template components onto your Skuid page below the Tasks Tab Set.
We’ll use these Templates to make sharp headers for our sections. Don’t worry about the default syntax in the Templates! We’re just about to change that.
- Click on the first Template component.
- Check the box next to Allow HTML and Do not run template on each row.
- Just in case you were wondering, don’t worry about the Model property for the Templates. We won’t be needing Model data to inform the content of these headers, so its not necessary to change the default Model.
- Copy and paste the following HTML code into the Template field in the first Template component:
<div class="nx-editor-header-title">Open Tasks</div>
- Click on the second Template component.
- Check the box next to Allow HTML and Do not run template on each row.
- Copy and paste the following HTML code into the Template field in the second Template component:
<div class="nx-editor-header-title">Completed Tasks</div>
Step 10: Add Tables to the Tasks tab.¶
- Click on the Components tab in the Page Composer.
- Drag and drop a Table component underneath the Open Tasks Template.
- Drag and drop a Table component underneath the Completed Tasks Template.
Set each Table to the appropriate Model.¶
- Select the Table under the Open Tasks template.
- In the Skuid Table Properties, choose OpenTasks as the Model.
- Select the Table under the Completed Tasks template.
- In the Skuid Table Properties, choose TaskHistory as the Model.
- Click on the Add Field(s) button on the Table component under Open Tasks.
- Click on Model Field(s).
Note
Make sure each Table is set to the correct Model before you add Fields! In this case, make sure the OpenTasks Model is selected.
- Click on All Fields.
Note
Since we did not add any Fields to the Model while we were adding and configuring the Model from the Models tab, we need to add Fields here to make them available for our Table. If you had added Fields directly to the Model, then those Fields would have appeared under the Selected Fields list.
- Click the Add field to model button to the Fields you want to add to your OpenTasks Table.
For this example, I have selected Subject, Contact/Lead ID, Priority, Status, Due Date Only, and Assigned To ID.
- Step 11 adds the Fields to the Model, but doesn’t add them to the Table. Add these Fields to the Table by checking the box next to the Fields you added.
- Repeat Substeps 8 -12 for the Table component under Completed Tasks.
For this example, I have selected the exact same Fields for each Model. You can change this up as you see fit.
Use Custom Labels to clean up Field Titles.¶
- Assign a Custom Label to each Field that has an unhelpful or confusing Field label. Of course, you can leave the Field names as they are, but you can add clarity to your information by using Custom Labels for your Fields. Makes your Tables much easier to interpret!
Note
You can use Custom Labels and Translations from Salesforce in this field.
For example, we changed:
- Contact/Lead ID to “Related To”
- Due Date Only to “Due Date” or “Date”
- Assigned To ID to “Assigned To.”
Step 11: Include the Javascript snippet to “Mark Tasks Completed”¶
- Click on the Resources Tab.
- Click Javascript.
- Click to add new resource.
Copy and paste this snippet to Mark Tasks Completed.¶
We’ll include this JS resource in a custom row action on our table. It will mark the task on that row completed.
- Click on your first new JS.
- Choose In-Line as the resource location.
- Name the snippet something like markCompleted.
- Click to open the Inline Code editor and copy and paste the following Javascript into the editor:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | skuid.snippet.registerSnippet('tasks.markCompleted',function(params){
console.log('test');
// Mark all selected items as closed,
// then save our 2 Tasks models
var model = params.model,
list = params.list,
selectedItems = params.item ? [params.item] : list.getSelectedItems();
if (selectedItems.length === 1 && skuid.model.isNewId(selectedItems[0].row.Id)) {
alert('Please finish creating this Task before marking it as completed.');
return;
}
$j.each(selectedItems,function(i,item){
model.updateRow(item.row,'Status','Completed');
});
// Block the list from having updates
list.element.block({
css: list.blockUICSS, overlayCSS: list.blockOverlayCSS,
message:'Marking Tasks as Completed...'
});
var saveFinishes = model.save({callback:
function(){
var updateFinishes = skuid.model.updateData([model,skuid.model.getModel('TaskHistory')]);
$j.when(updateFinishes).then(
function(){ list.element.unblock(); },
function(){ list.element.unblock(); }
);
}
});
});
|
Click on your Open Tasks table and click Add Features, then Add Row Action.¶
We’ll be adding one Row Action to this table.
Make the row action a custom action called Mark Completed.¶
- Click on the new row action.
- Choose Custom as the action type.
- Name the action Mark Completed.
- Choose a helpful action icon, such as ui-silk-tick.
- Enter the name of the markCompleted snippet: tasks.markCompleted (This is the registered name of the snippet in the code from Step 11).
Still in the Open Tasks Table, create a mass Mark Completed action.¶
- Click on your Open Tasks Table.
- Click Add Features and select Add Mass Action.
- Click on the new action and make it a Custom action drawing on the tasks.markCompleted snippet, just like the row action from Step 12.
Click on the Completed Tasks Table and edit its properties.¶
We don’t want people to be able to add tasks right to the Completed Tasks table. Thanks to our “Mark Completed” custom actions, completed tasks will be added there automatically. We do want people to be able to log calls and emails in this table, but we’ll do that by creating some Global Actions later in this step.
- Click on your Completed Tasks Table.
- Deselect “Allow Inline Record Creation.”
- You can also choose to deselect “Show Save/Cancel” and have just one Save/Cancel button for this page using a Button Set.
Step 12: Create row Popup to “View Task Details”¶
Click Add Features > Add Row Action¶
Select Popup for your Action Type.¶
- For Action Type select Popup.
- Label your action View Task Details.
- To select the icon choose from the icon directory or type in ui-silk-comments.
- Click on the button to select Configure popup and we will create your task detail page in the next step!
Configure your Popup.¶
- Drag and drop the Field Editor into the popup page. Make sure you select the correct Model (Open Tasks in this case). You may want to also set the field editor as Read Only and uncheck Show Save/Cancel.
- Now go to your model and select the appropriate fields (such as Subject, Description etc) and drag them into your field editor.
Success! You now have a Popup Row Action to view task details.¶
Step 13: Click Add Features > Add Global Actions.¶
Click on the first global action and make it a “Log an Email” redirect action.¶
Click on the first global action.
Choose Redirect as the action type.
Name it Log an Email.
Include a helpful icon, such as ui-silk-email.
For the URL, enter the following, substituting the name of the primary model on this page for OpportunityData:
/00T/e?title=Email%3A%20&what_id={{$Model.OpportunityData.data.0.Id15}}&tsk5=Email%3A%20&tsk10=Email&retURL=%2F{{$Param.id}}
Click on the second global action and make it a “Log a Call” redirect action.¶
Click on the second global action.
Choose Redirect as the action type.
Name it Log a Call.
Include a helpful icon, such as ui-silk-telephone.
For the URL, enter the following, substituting the name of the primary model on this page for OpportunityData:
/00T/e?title=Call%3A%20&what_id={{$Model.OpportunityData.data.0.Id15}}&tsk5=Call%3A%20&tsk10=Call&retURL=%2F{{$Param.id}}
Step 14: Add another tab to the Activities Tab Set.¶
The second Activities Tab will be a Calendar Tab that will pull in Events related to the main record.
Name this a Calendar Tab.¶
- Click on the new tab.
- Name the new tab Calendar.
- Add a helpful icon, such as ui-silk-calendar.
Step 15: Drag and drop a Calendar into this tab.¶
Click to add views to your calendar.¶
Click on a new View and select the Type from the list.¶
Step 16: Click to Add an Event Source.¶
This Event Source will pull data into the Calendar from a Model on your page.
Add an Events Model to use as your Event Source.¶
- Name your new model.
- Set it to the Event object.
- Click on the Advanced tab.
- Order by ActivityDate DESC
Add relevant fields to your Events model.¶
Add a condition that will only pull in events related to the main record on the page.¶
- Under Events, click Conditions > Add (+).
- For Field, choose What Id (Opportunity or Account ID).
- Click Value.
- Choose Url parameter as the content and Id as the parameter.
This will ensure that this Events model only includes events that are related to the main record on the page.
Click on your New Event Source and set it to the Events Model.¶
- In the Calendar, click on the New Event Source.
- Set it to the Events model.
- Select the appropriate fields, e.g. Subject for Name, Start Date Time for Start Field, End Date Time for End Field. (NB: For Start and End, you can use any Date Time field from any model).
- For Grouping Field, choose WhoId to group the events by related Contact.(Optional): Enter an event template that will be displayed in the calendar.
- (Optional): Choose an additional background color.
Step 17: Click to Add a second Event Source to this Calendar.¶
Add another Events model for this Event Source.¶
- Click to Add Model.
- Name your model OppOwner Events.
- Select the Event object.
- Include the appropriate fields.
Add a condition so that this Events model will pull in the calendar of the user viewing the page.¶
- Click to add a condition.
- For field, choose OwnerId.
- Click Value, then select UserInfo of page viewer.
This condition will ensure that this model will pull in only events that are owned by the person viewing this page.
Edit Page ~ salesforce.com - Enterprise Edition¶
- In the Calendar, click on the New Event Source.
- Set it to the OppOwner Events model.
- Select the appropriate fields, e.g. Subject for Name, Start Date Time for Start Field, End Date Time for End Field. (NB: For Start and End, you can use any Date Time field from any model).
- For Grouping Field, choose WhoId to group the events by related Contact.
- (Optional): Enter an event template that will be displayed in the calendar.
- (Optional): Choose an additional background color.
For more information about the Calendar component, including the day-scheduling view feature, see the Calendar topic.
Step 18: Click Save, then click Preview.¶
Choose the Opportunity you want to preview this page for.¶
The parent page we’re using for this Activities Tab is the Opportunity Detail page, so we have to choose an Opportunity to view this page for.
- Choose Opportunity as the object type.
- Start typing in the name of the opportunity and select it from the lookup list.
- Click Go.
Success! Your Activities tab will be displayed.¶
Click around to make sure everything is working properly.
Click on the events tab to view your calendar.¶
- Click on the Events tab.
- Click and drag to add an event to your calendar.
- A dialog will appear asking what type of event you want to create. From there, you can enter the event details.
Troubleshooting¶
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.