Skip to content

Commit

Permalink
Merge pull request salesforce#81 from Taost/customObject
Browse files Browse the repository at this point in the history
Rename custom object
  • Loading branch information
khawkins authored Nov 7, 2023
2 parents 97298f4 + dc54000 commit 9af31a1
Show file tree
Hide file tree
Showing 31 changed files with 131 additions and 131 deletions.
38 changes: 19 additions & 19 deletions docs/CustomObject.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Custom Object

[The custom object example](../force-app/main/default/objects/Visit__c) demonstrates the capability to work with custom objects in the Mobile Offline app. Like standard objects, users can view, create, and edit records of custom objects while their device is offline.
[The custom object example](../force-app/main/default/objects/StarterKitCustomObject__c) demonstrates the capability to work with custom objects in the Mobile Offline app. Like standard objects, users can view, create, and edit records of custom objects while their device is offline.

The following steps generally describe the setup of a custom object for use in offline scenarios. You can see a specific example of these steps in the "Configure" section below.
- Create a custom object and the associated fields needed for your use case.
Expand All @@ -14,37 +14,37 @@ The following steps generally describe the setup of a custom object for use in o
## Configure Custom Object

In this example, a `Visit` custom object is configured by deploying the relevant code artifacts to your org.
In this example, a `StarterKitCustomObject` custom object is configured by deploying the relevant code artifacts to your org.

1. Deploy the following code artifacts for the `Visit` object, in the order outlined below.
1. Deploy the following code artifacts for the `StarterKitCustomObject` object, in the order outlined below.

```sh
# Create the Visit object with 5 new fields
sfdx force:source:deploy -p force-app/main/default/objects/Visit__c
# Create the StarterKitCustomObject object with 5 new fields
sfdx force:source:deploy -p force-app/main/default/objects/StarterKitCustomObject__c

# Add LWCs
sfdx force:source:deploy -p force-app/main/default/lwc/viewVisitRecord
sfdx force:source:deploy -p force-app/main/default/lwc/createVisitRecord
sfdx force:source:deploy -p force-app/main/default/lwc/editVisitRecord
sfdx force:source:deploy -p force-app/main/default/lwc/viewStarterKitCustomObjectRecord
sfdx force:source:deploy -p force-app/main/default/lwc/createStarterKitCustomObjectRecord
sfdx force:source:deploy -p force-app/main/default/lwc/editStarterKitCustomObjectRecord

# Add quick actions
sfdx force:source:deploy -p force-app/main/default/quickActions/Visit__c.view.quickAction-meta.xml
sfdx force:source:deploy -p force-app/main/default/quickActions/Visit__c.create.quickAction-meta.xml
sfdx force:source:deploy -p force-app/main/default/quickActions/Visit__c.edit.quickAction-meta.xml
sfdx force:source:deploy -p force-app/main/default/quickActions/StarterKitCustomObject__c.view.quickAction-meta.xml
sfdx force:source:deploy -p force-app/main/default/quickActions/StarterKitCustomObject__c.create.quickAction-meta.xml
sfdx force:source:deploy -p force-app/main/default/quickActions/StarterKitCustomObject__c.edit.quickAction-meta.xml

# Add quick actions to the Visit Layout
sfdx force:source:deploy -p "force-app/main/default/layouts/Visit__c-Visit Layout.layout-meta.xml"
# Add quick actions to the StarterKitCustomObject Layout
sfdx force:source:deploy -p "force-app/main/default/layouts/StarterKitCustomObject__c-StarterKitCustomObject Layout.layout-meta.xml"

# Add the Visits tab for user to create records on the browser
sfdx force:source:deploy -p force-app/main/default/tabs/Visit__c.tab-meta.xml
# Add the StarterKitCustomObjects tab for user to create records on the browser
sfdx force:source:deploy -p force-app/main/default/tabs/StarterKitCustomObject__c.tab-meta.xml

# Add the permission set "Offline Custom Objects" for accessing Visit object
# Add the permission set "Offline Custom Objects" for accessing StarterKitCustomObject object
sfdx force:source:deploy -p force-app/main/default/permissionsets/Offline_Custom_Objects.permissionset-meta.xml
```

2. In your org, an org admin should assign the permission set `Offline Custom Objects` to org users.

3. [Configure your Offline Briefcase](../README.md#define-an-offline-briefcase) to include the `Visit` object.
- Make sure to create a few `Visit` records to be included in the briefcase.
3. [Configure your Offline Briefcase](../README.md#define-an-offline-briefcase) to include the `StarterKitCustomObject` object.
- Make sure to create a few `StarterKitCustomObject` records to be included in the briefcase.

4. Log in to the Mobile Offline App. You should see the new `Visit` object!
4. Log in to the Mobile Offline App. You should see the new `StarterKitCustomObject` object!
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,17 @@
<platformActionList>
<actionListContext>Record</actionListContext>
<platformActionListItems>
<actionName>Visit__c.view</actionName>
<actionName>StarterKitCustomObject__c.view</actionName>
<actionType>QuickAction</actionType>
<sortOrder>0</sortOrder>
</platformActionListItems>
<platformActionListItems>
<actionName>Visit__c.edit</actionName>
<actionName>StarterKitCustomObject__c.edit</actionName>
<actionType>QuickAction</actionType>
<sortOrder>1</sortOrder>
</platformActionListItems>
<platformActionListItems>
<actionName>Visit__c.create</actionName>
<actionName>StarterKitCustomObject__c.create</actionName>
<actionType>QuickAction</actionType>
<sortOrder>2</sortOrder>
</platformActionListItems>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { createElement } from "lwc";
import CreateVisitRecord from "c/createVisitRecord";
import CreateStarterKitCustomObjectRecord from "c/createStarterKitCustomObjectRecord";

import NAME_FIELD from "@salesforce/schema/Visit__c.Name";
import START_TIME__C_FIELD from "@salesforce/schema/Visit__c.Start_Time__c";
import END_TIME__C_FIELD from "@salesforce/schema/Visit__c.End_Time__c";
import PRIORITY__C_FIELD from "@salesforce/schema/Visit__c.Priority__c";
import STATUS__C_FIELD from "@salesforce/schema/Visit__c.Status__c";
import ADDRESS__C_FIELD from "@salesforce/schema/Visit__c.Address__c";
import NAME_FIELD from "@salesforce/schema/StarterKitCustomObject__c.Name";
import START_TIME__C_FIELD from "@salesforce/schema/StarterKitCustomObject__c.Start_Time__c";
import END_TIME__C_FIELD from "@salesforce/schema/StarterKitCustomObject__c.End_Time__c";
import PRIORITY__C_FIELD from "@salesforce/schema/StarterKitCustomObject__c.Priority__c";
import STATUS__C_FIELD from "@salesforce/schema/StarterKitCustomObject__c.Status__c";
import ADDRESS__C_FIELD from "@salesforce/schema/StarterKitCustomObject__c.Address__c";

describe("c-create-visit-record", () => {
describe("c-create-starter-kit-custom-object-record", () => {
afterEach(() => {
// The jsdom instance is shared across test cases in a single file, so, reset the DOM
while (document.body.firstChild) {
Expand All @@ -20,8 +20,8 @@ describe("c-create-visit-record", () => {

it("should go back when clicking cancel button", () => {
// setup
const element = createElement("c-create-visit-record", {
is: CreateVisitRecord,
const element = createElement("c-create-starter-kit-custom-object-record", {
is: CreateStarterKitCustomObjectRecord,
});
document.body.appendChild(element);

Expand All @@ -37,7 +37,7 @@ describe("c-create-visit-record", () => {
});

it("should populate correctly and have buttons, message, and input fields", () => {
const OBJECT_API_NAME = "Visit__c";
const OBJECT_API_NAME = "StarterKitCustomObject__c";

const INPUT_FIELDS = [
NAME_FIELD,
Expand All @@ -49,8 +49,8 @@ describe("c-create-visit-record", () => {
];

// setup
const element = createElement("c-create-visit-record", {
is: CreateVisitRecord,
const element = createElement("c-create-starter-kit-custom-object-record", {
is: CreateStarterKitCustomObjectRecord,
});
document.body.appendChild(element);

Expand Down Expand Up @@ -81,8 +81,8 @@ describe("c-create-visit-record", () => {

it("should go back after success", () => {
// setup
const element = createElement("c-create-visit-record", {
is: CreateVisitRecord,
const element = createElement("c-create-starter-kit-custom-object-record", {
is: CreateStarterKitCustomObjectRecord,
});
document.body.appendChild(element);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div class="component-background">
<lightning-record-edit-form object-api-name="Visit__c" onsuccess={onSuccess}>
<lightning-record-edit-form object-api-name="StarterKitCustomObject__c" onsuccess={onSuccess}>

<div class="header-slot">
<!-- cancel and submit buttons-->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { LightningElement, api } from "lwc";

import NAME_FIELD from "@salesforce/schema/Visit__c.Name";
import START_TIME__C_FIELD from "@salesforce/schema/Visit__c.Start_Time__c";
import END_TIME__C_FIELD from "@salesforce/schema/Visit__c.End_Time__c";
import PRIORITY__C_FIELD from "@salesforce/schema/Visit__c.Priority__c";
import STATUS__C_FIELD from "@salesforce/schema/Visit__c.Status__c";
import ADDRESS__C_FIELD from "@salesforce/schema/Visit__c.Address__c";
import NAME_FIELD from "@salesforce/schema/StarterKitCustomObject__c.Name";
import START_TIME__C_FIELD from "@salesforce/schema/StarterKitCustomObject__c.Start_Time__c";
import END_TIME__C_FIELD from "@salesforce/schema/StarterKitCustomObject__c.End_Time__c";
import PRIORITY__C_FIELD from "@salesforce/schema/StarterKitCustomObject__c.Priority__c";
import STATUS__C_FIELD from "@salesforce/schema/StarterKitCustomObject__c.Status__c";
import ADDRESS__C_FIELD from "@salesforce/schema/StarterKitCustomObject__c.Address__c";

export default class CreateVisit__cRecord extends LightningElement {
export default class CreateStarterKitCustomObject__cRecord extends LightningElement {
@api recordId;
@api objectApiName;

Expand All @@ -26,7 +26,7 @@ export default class CreateVisit__cRecord extends LightningElement {
address__c = "";

onSuccess(event) {
console.log("Created Visit__c", event.detail);
console.log("Created StarterKitCustomObject__c", event.detail);
// Dismiss modal on success
this.dismiss(event);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>56.0</apiVersion>
<isExposed>true</isExposed>
<masterLabel>Create Visit Record</masterLabel>
<description>Creates a new Visit.</description>
<masterLabel>Create StarterKitCustomObject Record</masterLabel>
<description>Creates a new StarterKitCustomObject.</description>
<targets>
<target>lightning__GlobalAction</target>
<target>lightning__RecordPage</target>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { createElement } from "lwc";
import EditVisitRecord from "c/editVisitRecord";
import EditStarterKitCustomObjectRecord from "c/editStarterKitCustomObjectRecord";
import { getRecord } from "lightning/uiRecordApi";

import NAME_FIELD from "@salesforce/schema/Visit__c.Name";
import START_TIME__C_FIELD from "@salesforce/schema/Visit__c.Start_Time__c";
import END_TIME__C_FIELD from "@salesforce/schema/Visit__c.End_Time__c";
import PRIORITY__C_FIELD from "@salesforce/schema/Visit__c.Priority__c";
import STATUS__C_FIELD from "@salesforce/schema/Visit__c.Status__c";
import ADDRESS__C_FIELD from "@salesforce/schema/Visit__c.Address__c";
import NAME_FIELD from "@salesforce/schema/StarterKitCustomObject__c.Name";
import START_TIME__C_FIELD from "@salesforce/schema/StarterKitCustomObject__c.Start_Time__c";
import END_TIME__C_FIELD from "@salesforce/schema/StarterKitCustomObject__c.End_Time__c";
import PRIORITY__C_FIELD from "@salesforce/schema/StarterKitCustomObject__c.Priority__c";
import STATUS__C_FIELD from "@salesforce/schema/StarterKitCustomObject__c.Status__c";
import ADDRESS__C_FIELD from "@salesforce/schema/StarterKitCustomObject__c.Address__c";

const mockRecord = require("./data/getRecord.json");

describe("c-edit-visit-record", () => {
describe("c-edit-starter-kit-custom-object-record", () => {
afterEach(() => {
// The jsdom instance is shared across test cases in a single file so reset the DOM
while (document.body.firstChild) {
Expand All @@ -21,10 +21,10 @@ describe("c-edit-visit-record", () => {

it("should correctly populate form and name field", () => {
const RECORD_ID = "001abcdefghijklmno";
const OBJECT_API_NAME = "Visit__c";
const OBJECT_API_NAME = "StarterKitCustomObject__c";

const element = createElement("c-edit-visit-record", {
is: EditVisitRecord,
const element = createElement("c-edit-starter-kit-custom-object-record", {
is: EditStarterKitCustomObjectRecord,
});
element.recordId = RECORD_ID;
element.objectApiName = OBJECT_API_NAME;
Expand Down Expand Up @@ -84,8 +84,8 @@ describe("c-edit-visit-record", () => {
});

it("should go back when clicking cancel button", () => {
const element = createElement("c-edit-visit-record", {
is: EditVisitRecord,
const element = createElement("c-edit-starter-kit-custom-object-record", {
is: EditStarterKitCustomObjectRecord,
});
document.body.appendChild(element);

Expand All @@ -101,8 +101,8 @@ describe("c-edit-visit-record", () => {
});

it("should go back after success", () => {
const element = createElement("c-edit-visit-record", {
is: EditVisitRecord,
const element = createElement("c-edit-starter-kit-custom-object-record", {
is: EditStarterKitCustomObjectRecord,
});
document.body.appendChild(element);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div class="component-background">
<lightning-record-edit-form object-api-name="Visit__c" record-id={recordId} onsuccess={onSuccess}>
<lightning-record-edit-form object-api-name="StarterKitCustomObject__c" record-id={recordId} onsuccess={onSuccess}>
<div class="header-slot">
<!-- cancel and submit buttons-->
<lightning-layout horizontal-align="spread" class="slds-var-p-horizontal_xx-small">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { LightningElement, api, wire } from "lwc";
import { getRecord } from "lightning/uiRecordApi";

import NAME_FIELD from "@salesforce/schema/Visit__c.Name";
import START_TIME__C_FIELD from "@salesforce/schema/Visit__c.Start_Time__c";
import END_TIME__C_FIELD from "@salesforce/schema/Visit__c.End_Time__c";
import PRIORITY__C_FIELD from "@salesforce/schema/Visit__c.Priority__c";
import STATUS__C_FIELD from "@salesforce/schema/Visit__c.Status__c";
import ADDRESS__C_FIELD from "@salesforce/schema/Visit__c.Address__c";
import NAME_FIELD from "@salesforce/schema/StarterKitCustomObject__c.Name";
import START_TIME__C_FIELD from "@salesforce/schema/StarterKitCustomObject__c.Start_Time__c";
import END_TIME__C_FIELD from "@salesforce/schema/StarterKitCustomObject__c.End_Time__c";
import PRIORITY__C_FIELD from "@salesforce/schema/StarterKitCustomObject__c.Priority__c";
import STATUS__C_FIELD from "@salesforce/schema/StarterKitCustomObject__c.Status__c";
import ADDRESS__C_FIELD from "@salesforce/schema/StarterKitCustomObject__c.Address__c";

export default class EditVisit__cRecord extends LightningElement {
export default class EditStarterKitCustomObject__cRecord extends LightningElement {
@api recordId;
@api objectApiName;

Expand All @@ -32,7 +32,7 @@ export default class EditVisit__cRecord extends LightningElement {
}

onSuccess(event) {
console.log("Updated Visit__c", event.detail);
console.log("Updated StarterKitCustomObject__c", event.detail);
// Dismiss modal on success
this.dismiss(event);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"fields": {
"Name": {
"value": "Mock Visit"
"value": "Mock StarterKitCustomObject"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { createElement } from "lwc";
import ViewVisitRecord from "c/viewVisitRecord";
import ViewStarterKitCustomObjectRecord from "c/viewStarterKitCustomObjectRecord";
import { getRecord } from "lightning/uiRecordApi";
import NAME_FIELD from "@salesforce/schema/Visit__c.Name";
import START_TIME__C_FIELD from "@salesforce/schema/Visit__c.Start_Time__c";
import END_TIME__C_FIELD from "@salesforce/schema/Visit__c.End_Time__c";
import PRIORITY__C_FIELD from "@salesforce/schema/Visit__c.Priority__c";
import STATUS__C_FIELD from "@salesforce/schema/Visit__c.Status__c";
import ADDRESS__C_FIELD from "@salesforce/schema/Visit__c.Address__c";
import NAME_FIELD from "@salesforce/schema/StarterKitCustomObject__c.Name";
import START_TIME__C_FIELD from "@salesforce/schema/StarterKitCustomObject__c.Start_Time__c";
import END_TIME__C_FIELD from "@salesforce/schema/StarterKitCustomObject__c.End_Time__c";
import PRIORITY__C_FIELD from "@salesforce/schema/StarterKitCustomObject__c.Priority__c";
import STATUS__C_FIELD from "@salesforce/schema/StarterKitCustomObject__c.Status__c";
import ADDRESS__C_FIELD from "@salesforce/schema/StarterKitCustomObject__c.Address__c";

const mockGetRecord = require("./data/getRecord.json");

describe("c-view-visit-record", () => {
describe("c-view-starter-kit-custom-object-record", () => {
afterEach(() => {
// The jsdom instance is shared across test cases in a single file so reset the DOM
while (document.body.firstChild) {
Expand All @@ -19,11 +19,11 @@ describe("c-view-visit-record", () => {
});

it("should correctly populate record fields", async () => {
const element = createElement("c-view-visit-record", {
is: ViewVisitRecord,
const element = createElement("c-view-starter-kit-custom-object-record", {
is: ViewStarterKitCustomObjectRecord,
});
element.recordId = "0011700000pJRRSAA4";
element.objectApiName = "Visit";
element.objectApiName = "StarterKitCustomObject";
document.body.appendChild(element);

// Emit mock record into the wired field
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<div class="title-slot">
<c-record-header record-name={name} object-api-name={objectApiName}
object-label="Visit" icon-name="custom:custom9">
object-label="StarterKitCustomObject" icon-name="custom:custom9">
</c-record-header>
</div>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { LightningElement, api, wire } from "lwc";
import { getRecord } from "lightning/uiRecordApi";
import NAME_FIELD from "@salesforce/schema/StarterKitCustomObject__c.Name";
import START_TIME__C_FIELD from "@salesforce/schema/StarterKitCustomObject__c.Start_Time__c";
import END_TIME__C_FIELD from "@salesforce/schema/StarterKitCustomObject__c.End_Time__c";
import PRIORITY__C_FIELD from "@salesforce/schema/StarterKitCustomObject__c.Priority__c";
import STATUS__C_FIELD from "@salesforce/schema/StarterKitCustomObject__c.Status__c";
import ADDRESS__C_FIELD from "@salesforce/schema/StarterKitCustomObject__c.Address__c";

export default class ViewStarterKitCustomObject__cRecord extends LightningElement {
@api recordId;
@api objectApiName;

get fields() {
return [
NAME_FIELD,
START_TIME__C_FIELD,
END_TIME__C_FIELD,
PRIORITY__C_FIELD,
STATUS__C_FIELD,
ADDRESS__C_FIELD,
];
}

@wire(getRecord, { recordId: "$recordId", fields: "$fields" })
record;

get name() {
return this.record?.data?.fields?.Name?.value ?? "";
}
}
Loading

0 comments on commit 9af31a1

Please sign in to comment.