Added in 24.2.
In this guide, you will learn about how to add custom fields to the Salesforce case portal in the Aurora community.
To create custom fields, you must use the createOrUpdateCustomFieldDefinitions
mutation. To learn more about how to set custom fields, see Introduction to Custom Fields.
In this example, we are going to create two fields:
- Community Tags
- Lithium User replied
Note: You must always pass all the custom fields that you want to render on the form. If you pass a single field, it overrides the existing fields and only the newly added field is displayed.
Retrieve the existing custom fields
To retrieve the list of the existing custom fields, use the below GraphQL query.
query {
customFieldsEntityDefinitions(entityTypes: [SALESFORCE_CASE]) {
definition {
customFieldNames
}
}
}
Create field definitions
Here is the createOrUpdateCustomFieldDefinitions
mutation where we are creating community tags and lithium user replied.
mutation {
createOrUpdateCustomFieldDefinitions(
entityDefinitionInputs: {
type: SALESFORCE_CASE
customFieldNames: [
"LiSFIntegration__Community_Tags__c",
"LiSFIntegration__Lithium_User_Replied__c"
]
}
fieldDefinitionInputs: [
{
name: "LiSFIntegration__Community_Tags__c"
returnable: true
createable: YES
editable: YES
removable: false
access: { read: PUBLIC, write: PUBLIC }
valueDefinition: {
string: {
validationRules: {
allowedCharacters: ALPHA_NUMERIC_WHITESPACE_SPECIAL_CHARACTERS
}
queryDefinition: {
constraintDefinition: { operators: IN }
sortable: false
}
createEntityFormField: { input: { inputType: TEXT } }
updateEntityFormField: { input: { inputType: TEXT } }
}
}
}
{
name: "LiSFIntegration__Lithium_User_Replied__c"
returnable: true
createable: YES
editable: YES
removable: false
access: { read: PUBLIC, write: PUBLIC }
valueDefinition: {
boolean: {
queryDefinition: { constraintDefinition: { operators: EQ } }
createEntityFormField: { check: { defaultValue: false } }
updateEntityFormField: { check: { defaultValue: false } }
}
}
}
]
) {
result {
fieldDefinitions {
definition {
name
}
}
}
errors {
... on CreateOrUpdateCustomFieldDefinitionFailedError {
message
fields
fieldName
}
... on CreateOrUpdateCustomFieldsEntityDefinitionFailedError {
message
fields
entityType
}
}
}
}
Here is the response to the mutation.
{
"data": {
"createOrUpdateCustomFieldDefinitions": {
"result": {
"fieldDefinitions": [
{
"definition": {
"name": "LiSFIntegration__Community_Tags__c"
}
},
{
"definition": {
"name": "LiSFIntegration__Lithium_User_Replied__c"
}
}
]
},
"errors": null
}
}
}
Create text overrides for the custom fields
After the successful creation of the custom fields into the mosaic repository, we must define the display field name (label) for the User Interface (UI).
To define the label, we need the componentId
of the widget.
To retrieve the componentId
, you must look into the codebase.
Based on the codebase, the following table shows the relationship between the componentId
and the text key.
Page | Component Id | Text Key Format (as per codebase) (customFieldName should be in camel case that is the first letter must be in lower case) |
---|---|---|
Create Case Page | salesforce.block.createCaseForm | CreateCaseForm.custom.<customFieldName>.label |
Update Case Modal | salesforce.block.updateCaseModal | UpdateCaseForm.custom.<customFieldName>.label |
Case Details Page | salesforce.widget.caseViewWidget | customFieldName |
Case Portal Dashboard | salesforce.block.casePortalDashboard | customColumn.customFieldName |
Case Portal Filters | salesforce.block.casePortalDashboardFilters | CasePortalDashboardFilters.custom.<customFieldName>.label |
Here is the mutation to add the following labels to the custom fields for the Create Case page.
- Lithium User Replied - Has Khoros User replied
- Community - Case tags
mutation {
createOrUpdateTextOverride(
componentId: "salesforce.block.createCaseForm"
locale: "en"
values: {
"CreateCaseForm.custom.LiSFIntegration__Lithium_User_Replied__c.label": "Has Khoros User replied"
"CreateCaseForm.custom.LiSFIntegration__Community_Tags__c.label": "Case tags"
}
) {
result {
locale
texts
}
errors {
... on CreateOrUpdateTextFailedError{
message
fields
name
}
}
}
}
If the above mutation format is not accepted by your GraphQL client, you can define a JSON object in the GraphQL variables and use that GraphQL variable in the mutation.
Here is an example for the caseViewWidget.
mutation ($values: JSON!){
createOrUpdateTextOverride(
componentId: "salesforce.widget.caseViewWidget"
locale: "en"
values: $values
) {
result {
locale
texts
}
errors {
... on CreateOrUpdateTextFailedError {
message
fields
name
}
}
}
}
Here are the variables to accompany the mutation.
{
"values":{
"custom_Priority__c":"Priority",
"steps_to_reproduce__c": "Steps to reproduce",
"browser_os__c":"Browser and OS details"
}
}
After the successful creation of the custom fields and mapping to the display text of the UI, you must contact support to add the custom fields to the config file.
ATLAS
Comments