Closed16
Salesforce GraphQL - Trial to get PicklistValue
参考
Create scratch org
sf org create scratch --edition developer --no-namespace --alias demo-userorg
Confirm created
sf org list
Insert account record
- New record
- Name:
Foo
- Type:
Customer - Direct
- Name:
Via Web Page
Via Developer Console - Query Editor
SELECT Id, Name, Type FROM Account
Type
of Account
Describe field Via Object Manager
-
値
equalAPI参照名
Via REST API
curl -X GET -H 'Content-Type: application/json' -H "Authorization: Bearer ${access_token}" "${instance_url}/services/data/v58.0/sobjects/Account/describe/"
-
label
equalvalue
inpicklistValues
// omission
{
"aggregatable": true,
"aiPredictionField": false,
"autoNumber": false,
"byteLength": 765,
"calculated": false,
"calculatedFormula": null,
"cascadeDelete": false,
"caseSensitive": false,
"compoundFieldName": null,
"controllerName": null,
"createable": true,
"custom": false,
"defaultValue": null,
"defaultValueFormula": null,
"defaultedOnCreate": false,
"dependentPicklist": false,
"deprecatedAndHidden": false,
"digits": 0,
"displayLocationInDecimal": false,
"encrypted": false,
"externalId": false,
"extraTypeInfo": null,
"filterable": true,
"filteredLookupInfo": null,
"formulaTreatNullNumberAsZero": false,
"groupable": true,
"highScaleNumber": false,
"htmlFormatted": false,
"idLookup": false,
"inlineHelpText": null,
"label": "取引先 種別",
"length": 255,
"mask": null,
"maskType": null,
"name": "Type",
"nameField": false,
"namePointing": false,
"nillable": true,
"permissionable": true,
"picklistValues": [
{
"active": true,
"defaultValue": false,
"label": "Prospect",
"validFor": null,
"value": "Prospect"
},
{
"active": true,
"defaultValue": false,
"label": "Customer - Direct",
"validFor": null,
"value": "Customer - Direct"
},
{
"active": true,
"defaultValue": false,
"label": "Customer - Channel",
"validFor": null,
"value": "Customer - Channel"
},
{
"active": true,
"defaultValue": false,
"label": "Channel Partner / Reseller",
"validFor": null,
"value": "Channel Partner / Reseller"
},
{
"active": true,
"defaultValue": false,
"label": "Installation Partner",
"validFor": null,
"value": "Installation Partner"
},
{
"active": true,
"defaultValue": false,
"label": "Technology Partner",
"validFor": null,
"value": "Technology Partner"
},
{
"active": true,
"defaultValue": false,
"label": "Other",
"validFor": null,
"value": "Other"
}
],
"polymorphicForeignKey": false,
"precision": 0,
"queryByDistance": false,
"referenceTargetField": null,
"referenceTo": [],
"relationshipName": null,
"relationshipOrder": null,
"restrictedDelete": false,
"restrictedPicklist": false,
"scale": 0,
"searchPrefilterable": false,
"soapType": "xsd:string",
"sortable": true,
"type": "picklist",
"unique": false,
"updateable": true,
"writeRequiresMasterRead": false
},
// omission
Get Accounts by GraphQL
GraphQL Request body
accounts_with_picklist.json
{
"query": "query accounts {
uiapi {
query {
Account {
edges {
node {
Id
Name { value }
Type {
value
label
displayValue
}
}
}
}
}
}
}"
}
Request to GraphQL
curl -X POST -H 'Content-Type: application/json' -H "Authorization: Bearer ${access_token}" "${instance_url}/services/data/v58.0/graphql" -d @accounts_with_picklist.json
response
{
"data": {
"uiapi": {
"query": {
"Account": {
"edges": [
{
"node": {
"Id": "0011m00000lxQLAAA2",
"Name": {
"value": "Foo"
},
"Type": {
"value": "Customer - Direct",
"label": "Customer - Direct",
"displayValue": "Customer - Direct"
}
}
},
{
"node": {
"Id": "0011m00000lzjq8AAA",
"Name": {
"value": "Sample Account for Entitlements"
},
"Type": {
"value": null,
"label": null,
"displayValue": null
}
}
}
]
}
}
}
},
"errors": []
}
Add new Picklist field to Account
- New field
- Label:
extra_type
- Name:
extra_type
- Values:
Foo
Bar
Baz
- Label:
Values after field created
extra_type
of current Account record
Edit field Via Web Page
Via Developer Console - Query Editor
SELECT Id, Name, Type, extra_type__c FROM Account
extra_type__c
created
Get Accounts by GraphQL (2) - after GraphQL Request body
accounts_with_picklist.json
{
"query": "query accounts {
uiapi {
query {
Account {
edges {
node {
Id
Name { value }
Type {
value
label
displayValue
}
extra_type__c {
value
label
displayValue
}
}
}
}
}
}
}"
}
Request to GraphQL
curl -X POST -H 'Content-Type: application/json' -H "Authorization: Bearer ${access_token}" "${instance_url}/services/data/v58.0/graphql" -d @accounts_with_picklist.json
response
{
"data": {
"uiapi": {
"query": {
"Account": {
"edges": [
{
"node": {
"Id": "0011m00000lxQLAAA2",
"Name": {
"value": "Foo"
},
"Type": {
"value": "Customer - Direct",
"label": "Customer - Direct",
"displayValue": "Customer - Direct"
},
"extra_type__c": {
"value": "Foo",
"label": "Foo",
"displayValue": "Foo"
}
}
},
{
"node": {
"Id": "0011m00000lzjq8AAA",
"Name": {
"value": "Sample Account for Entitlements"
},
"Type": {
"value": null,
"label": null,
"displayValue": null
},
"extra_type__c": {
"value": null,
"label": null,
"displayValue": null
}
}
}
]
}
}
}
},
"errors": []
}
extra_type__c
- label of values
Edit field Via Object Manager
-
値
not equalAPI参照名
Via REST API
-
label
not equalvalue
inpicklistValues
// omission
{
"aggregatable": true,
"aiPredictionField": false,
"autoNumber": false,
"byteLength": 765,
"calculated": false,
"calculatedFormula": null,
"cascadeDelete": false,
"caseSensitive": false,
"compoundFieldName": null,
"controllerName": null,
"createable": true,
"custom": true,
"defaultValue": null,
"defaultValueFormula": null,
"defaultedOnCreate": false,
"dependentPicklist": false,
"deprecatedAndHidden": false,
"digits": 0,
"displayLocationInDecimal": false,
"encrypted": false,
"externalId": false,
"extraTypeInfo": null,
"filterable": true,
"filteredLookupInfo": null,
"formulaTreatNullNumberAsZero": false,
"groupable": true,
"highScaleNumber": false,
"htmlFormatted": false,
"idLookup": false,
"inlineHelpText": null,
"label": "extra_type",
"length": 255,
"mask": null,
"maskType": null,
"name": "extra_type__c",
"nameField": false,
"namePointing": false,
"nillable": true,
"permissionable": true,
"picklistValues": [
{
"active": true,
"defaultValue": false,
"label": "Label - Foo",
"validFor": null,
"value": "Foo"
},
{
"active": true,
"defaultValue": false,
"label": "Label - Bar",
"validFor": null,
"value": "Bar"
},
{
"active": true,
"defaultValue": false,
"label": "Label - Baz",
"validFor": null,
"value": "Baz"
}
],
"polymorphicForeignKey": false,
"precision": 0,
"queryByDistance": false,
"referenceTargetField": null,
"referenceTo": [],
"relationshipName": null,
"relationshipOrder": null,
"restrictedDelete": false,
"restrictedPicklist": true,
"scale": 0,
"searchPrefilterable": false,
"soapType": "xsd:string",
"sortable": true,
"type": "picklist",
"unique": false,
"updateable": true,
"writeRequiresMasterRead": false
}
// omission
extra_type__c
label of values
View Account records after edit field - In Web Page,
Label
change. -
extra_type__c
value of record does not change.
Via Web Page
Via Developer Console - Query Editor
SELECT Id, Name, Type, extra_type__c FROM Account
extra_type__c
label of vlaues edited
Get Accounts by GraphQL (3) - after GraphQL Request body
accounts_with_picklist.json
{
"query": "query accounts {
uiapi {
query {
Account {
edges {
node {
Id
Name { value }
Type {
value
label
displayValue
}
extra_type__c {
value
label
displayValue
}
}
}
}
}
}
}"
}
Request to GraphQL
curl -X POST -H 'Content-Type: application/json' -H "Authorization: Bearer ${access_token}" "${instance_url}/services/data/v58.0/graphql" -d @accounts_with_picklist.json
- In
extra_type__c
,value
andlabel
are different.
response
{
"data": {
"uiapi": {
"query": {
"Account": {
"edges": [
{
"node": {
"Id": "0011m00000lxQLAAA2",
"Name": {
"value": "Foo"
},
"Type": {
"value": "Customer - Direct",
"label": "Customer - Direct",
"displayValue": "Customer - Direct"
},
"extra_type__c": {
"value": "Foo",
"label": "Label - Foo",
"displayValue": "Label - Foo"
}
}
},
{
"node": {
"Id": "0011m00000lzjq8AAA",
"Name": {
"value": "Sample Account for Entitlements"
},
"Type": {
"value": null,
"label": null,
"displayValue": null
},
"extra_type__c": {
"value": null,
"label": null,
"displayValue": null
}
}
}
]
}
}
}
},
"errors": []
}
extra_type__c
value of values
Edit field Via Object Manager
Via REST API
// omission
{
"aggregatable": true,
"aiPredictionField": false,
"autoNumber": false,
"byteLength": 765,
"calculated": false,
"calculatedFormula": null,
"cascadeDelete": false,
"caseSensitive": false,
"compoundFieldName": null,
"controllerName": null,
"createable": true,
"custom": true,
"defaultValue": null,
"defaultValueFormula": null,
"defaultedOnCreate": false,
"dependentPicklist": false,
"deprecatedAndHidden": false,
"digits": 0,
"displayLocationInDecimal": false,
"encrypted": false,
"externalId": false,
"extraTypeInfo": null,
"filterable": true,
"filteredLookupInfo": null,
"formulaTreatNullNumberAsZero": false,
"groupable": true,
"highScaleNumber": false,
"htmlFormatted": false,
"idLookup": false,
"inlineHelpText": null,
"label": "extra_type",
"length": 255,
"mask": null,
"maskType": null,
"name": "extra_type__c",
"nameField": false,
"namePointing": false,
"nillable": true,
"permissionable": true,
"picklistValues": [
{
"active": true,
"defaultValue": false,
"label": "Label - Foo",
"validFor": null,
"value": "FooValue"
},
{
"active": true,
"defaultValue": false,
"label": "Label - Bar",
"validFor": null,
"value": "BarValue"
},
{
"active": true,
"defaultValue": false,
"label": "Label - Baz",
"validFor": null,
"value": "BazValue"
}
],
"polymorphicForeignKey": false,
"precision": 0,
"queryByDistance": false,
"referenceTargetField": null,
"referenceTo": [],
"relationshipName": null,
"relationshipOrder": null,
"restrictedDelete": false,
"restrictedPicklist": true,
"scale": 0,
"searchPrefilterable": false,
"soapType": "xsd:string",
"sortable": true,
"type": "picklist",
"unique": false,
"updateable": true,
"writeRequiresMasterRead": false
}
// omission
extra_type__c
value of values
View Account records after edit field - In Web Page,
Label
does not change. -
extra_type__c
value of record change.
VIa Web Page
Via Developer Console - Query Editor
extra_type__c
value of values edited
Get Accounts by GraphQL (4) - after GraphQL Request body
accounts_with_picklist.json
{
"query": "query accounts {
uiapi {
query {
Account {
edges {
node {
Id
Name { value }
Type {
value
label
displayValue
}
extra_type__c {
value
label
displayValue
}
}
}
}
}
}
}"
}
Request to GraphQL
curl -X POST -H 'Content-Type: application/json' -H "Authorization: Bearer ${access_token}" "${instance_url}/services/data/v58.0/graphql" -d @accounts_with_picklist.json
response
{
"data": {
"uiapi": {
"query": {
"Account": {
"edges": [
{
"node": {
"Id": "0011m00000lxQLAAA2",
"Name": {
"value": "Foo"
},
"Type": {
"value": "Customer - Direct",
"label": "Customer - Direct",
"displayValue": "Customer - Direct"
},
"extra_type__c": {
"value": "FooValue",
"label": "Label - Foo",
"displayValue": "Label - Foo"
}
}
},
{
"node": {
"Id": "0011m00000lzjq8AAA",
"Name": {
"value": "Sample Account for Entitlements"
},
"Type": {
"value": null,
"label": null,
"displayValue": null
},
"extra_type__c": {
"value": null,
"label": null,
"displayValue": null
}
}
}
]
}
}
}
},
"errors": []
}
Edit field extra_type__c value of values disabled
Via Object Manager
Via Web Page
View
- already has set disabled value, does not change.
New Page
- Disabled value does not display in candidates.
Via Developer Console - Query Editor
SELECT Id, Name, Type, extra_type__c FROM Account
extra_type__c
value of values disabled
Get Accounts by GraphQL (5) - after GraphQL Request body
accounts_with_picklist.json
{
"query": "query accounts {
uiapi {
query {
Account {
edges {
node {
Id
Name { value }
Type {
value
label
displayValue
}
extra_type__c {
value
label
displayValue
}
}
}
}
}
}
}"
}
Request to GraphQL
curl -X POST -H 'Content-Type: application/json' -H "Authorization: Bearer ${access_token}" "${instance_url}/services/data/v58.0/graphql" -d @accounts_with_picklist.json
response
{
"data": {
"uiapi": {
"query": {
"Account": {
"edges": [
{
"node": {
"Id": "0011m00000lxQLAAA2",
"Name": {
"value": "Foo"
},
"Type": {
"value": "Customer - Direct",
"label": "Customer - Direct",
"displayValue": "Customer - Direct"
},
"extra_type__c": {
"value": "FooValue",
"label": "Label - Foo",
"displayValue": "Label - Foo"
}
}
},
{
"node": {
"Id": "0011m00000lzjq8AAA",
"Name": {
"value": "Sample Account for Entitlements"
},
"Type": {
"value": null,
"label": null,
"displayValue": null
},
"extra_type__c": {
"value": null,
"label": null,
"displayValue": null
}
}
}
]
}
}
}
},
"errors": []
}
このスクラップは2023/09/10にクローズされました