我有一个名为医疗记录的实体
我正在获取病历实体(子网格)中的家庭列表
我可以使用api call
获取家庭列表 http://localhost/CRMDataBase/api/data/v8.0/new_medcase(1a7f5ac3-b116-e611-9425-000d3a12d0d4)?$expand=new_case_family
但问题是,我想从下拉字段获取文本而不是系列中的值。 即我有一个名为new_typeoffamily的字段,它具有“核”,“联合”等值 但api调用取值为100000,1000001
如何使用api调用选择文本?
答案 0 :(得分:4)
我相信您需要将查询设置为也返回格式化值。
请求:
GET [Organization URI]/api/data/v8.1/accounts?$select=name,donotpostalmail,accountratingcode,numberofemployees,revenue&$top=1 HTTP/1.1
Accept: application/json
OData-MaxVersion: 4.0
OData-Version: 4.0
Prefer: odata.include-annotations="OData.Community.Display.V1.FormattedValue"
结果:
HTTP/1.1 200 OK
Content-Type: application/json; odata.metadata=minimal
OData-Version: 4.0
Preference-Applied: odata.include-annotations="OData.Community.Display.V1.FormattedValue"
{
"@odata.context": "[Organization URI]/api/data/v8.1/$metadata#accounts(name,donotpostalmail,accountratingcode,numberofemployees,revenue)",
"value": [
{
"@odata.etag": "W/"502170"",
"name": "Fourth Coffee (sample)",
"donotpostalmail@OData.Community.Display.V1.FormattedValue": "Allow",
"donotpostalmail": false,
"accountratingcode@OData.Community.Display.V1.FormattedValue": "Default Value",
"accountratingcode": 1,
"numberofemployees@OData.Community.Display.V1.FormattedValue": "9,500",
"numberofemployees": 9500,
"revenue@OData.Community.Display.V1.FormattedValue": "$100,000.00",
"revenue": 100000,
"accountid": "89390c24-9c72-e511-80d4-00155d2a68d1",
"transactioncurrencyid_value": "50b6dd7b-f16d-e511-80d0-00155db07cb1" } ]
}
答案 1 :(得分:3)
在发出请求之前添加以下标题
parent.$.ajax({
url : customurl,
headers: {
"Accept": "application/json" ,
"Content-Type":"application/json; charset=utf-8",
"OData-MaxVersion":"4.0",
"OData-Version":"4.0",
"Prefer":"odata.include-annotations=OData.Community.Display.V1.FormattedValue"
},
现在数据将具有类似之前的值
new_modeofcontact: 1000001
new_modeofcontact@OData.Community.Display.V1.FormattedValue : "Email"