Save & update records in objects
There is always a need to ensure records are kept up to date and have the latest contact details, sales figures, or case details. The Salesforce Save or Update methods allow you to update records in Salesforce directly from your mobile device.
Examples and code snippets
Examples are based on test data in a Jigx demo Salesforce environment. Copying the sample code must be adjusted to represent your own Salesforce environment.
This example shows how to update a Salesforce Opportunity record. From the list of opportunities using the onPress action the jig opens a form showing the opportunity name and amount. Edit the amount field. Using the Salesforce Providers save method the opportunity is updated.
:::CodeblockTabs
title: Opportunity Update
description: Update the opportunity Amount
type: jig.default
header:
type: component.jig-header
options:
children:
type: component.image
options:
source:
uri: https://images.unsplash.com/photo-1509228627152-72ae9ae6848d?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=1470&q=80
height: medium
datasources:
opp-amount:
type: datasource.sqlite
options:
provider: DATA_PROVIDER_LOCAL
entities:
- entity: Opportunity
query: SELECT id, '$.Name', '$.Amount' FROM [Opportunity] WHERE id = @id
queryParameters:
id: [email protected]
children:
- type: component.form
instanceId: opp-form
options:
children:
- type: component.text-field
instanceId: id
options:
initialValue: [email protected]
isHidden: true
label: id
- type: component.text-field
instanceId: Name
options:
label: Opportunity Name
initialValue: [email protected]
- type: component.number-field
instanceId: Amount
options:
label: Amount
initialValue: [email protected]
actions:
- children:
- type: action.submit-form
options:
title: Update Amount
provider: DATA_PROVIDER_SALESFORCE
entity: Opportunity
formId: opp-form
method: save
data:
id: [email protected]
Amount: [email protected]
onSuccess:
type: action.go-back title: List Salesforce opportunities
type: jig.default
header:
type: component.jig-header
options:
height: medium
children:
type: component.image
options:
source:
uri: https://images.unsplash.com/photo-1454165804606-c3d57bc86b40?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=1170&q=80
onFocus:
type: action.action-list
options:
actions:
- type: action.sync-entities
options:
provider: DATA_PROVIDER_SALESFORCE
entities:
- entity: Opportunity
datasources:
salesforce-opp-list:
type: datasource.sqlite
options:
provider: DATA_PROVIDER_LOCAL
entities:
- entity: Opportunity
query: SELECT id, '$.Name', '$.Amount' FROM [Opportunity]
children:
- type: component.list
instanceId: account-list
options:
data: [email protected]
item:
type: component.list-item
options:
title: [email protected]
leftElement:
element: avatar
text: SF
rightElement:
element: value
text:
format:
currency: USD
numberStyle: currency
text: [email protected]
onPress:
type: action.go-to
options:
linkTo: salesforce-opp-update
inputs:
id: [email protected]
entity: OpportunityLast updated
Was this helpful?