Recently I am working on an issue regarding my responsible application and I found out that previously I have wrong understanding on the image handling in CRM Fiori. I share the correct one in this knowledge so that you would not make similar mistake that I made before.
Background
In CRM Fiori application “My Opportunity”, if the account for current Opportunity has maintained image in CRM backend, it will then be displayed in Fiori UI.
How to maintain account Logo in CRM so that it could be displayed in Fiori UI
We have to launch CRM WebUI, upload a new attachment for given account:
This attachment should meet the following criteria, to make sure it could be used as logo for the current account:
(1) it must be an image file ( type JPEG Graphic or other image format ) (2) in property maintenance window, it must be set as default document among all attachments and document type must be BDS_IMAGE.
In the runtime, when you open Fiori UI, it takes two steps to get the image rendered in UI finally. These two steps could just be observed in the Chrome network tab.
Step1 – Fiori UI asks for the image URL from backend
Previously, I consider Fiori UI asked the binary content of image from backend, this is COMPLETELY WRONG! The complete url for the first step: https://:/sap/opu/odata/sap/ZJERRY_DEMO_SRV/AccountCollection(‘4031140’)?$expand=Logo From url we know there is an expand operation on node Logo. Check response in Chrome, there is no image binary source contained in response.
the url contained in Logo node is used as the requested url for the second step, as could be observed in Chrome:
: The complete url returned by first step: https://:/sap/opu/odata/sap/ZJERRY_DEMO_SRV/AttachmentCollection(documentID=‘FA163EEF573D1EE585804C8B6241ABA3′,documentClass=’BDS_POC1′,businessPartnerID=’4031140’)/$value Although it contains an “Attachment” in url, it HAS NOTHING TO DO WITH the tab in Opportunity detail page! It just indicates that the technical storage of account logo is done via CRM Attachment model.
Step2 – bind the url to image field in application
Check the xml binding path for image field in Opportunity detail view: it is bound to ImgSrc in json model.
In application code, it just fills that json model field with url returned by step 1:
And this operation will lead to a delayed re-render later to set the native html property “src” for image field, which is done by framework:
Callstack:
Conclusion
The http request sent in second step is not issued by My Opportunity application, but by browser itself, once an image element is filled with actual url on its “src” property. To simply prove this conclusion: Create a simple html file as below, just paste the url for second step into src property:
<html>
<img src="https://<hostname>:<port>/sap/opu/odata/sap/ZJERRY_DEMO_SRV/AttachmentCollection(documentID='FA163EEF573D1EE585804C8B6241ABA3',documentClass='BDS_POC1',businessPartnerID='4031140')/$value"></img>
<html>
Open it in Chrome, and you can observe exactly the same network behavior as when you open the application with an image in Fiori UI:
要获取更多Jerry的原创文章,请关注公众号"汪子熙":
文摘归档
- 2021年01月(8)
- 2020年10月(10)
- 2020年09月(13)
- 2020年05月(35)
- 2019年04月(2)
- 2019年03月(6)
- 2019年02月(29)
- 2019年01月(61)
- 2018年12月(14)
阅读排行榜
- 如何把某个网站的SSL Server certificate链导入到ABAP Netweaver系统里 (534)
- SAP C/4HANA Sales Cloud使用OData服务和第三方系统集成的一个具体例子 (519)
- 基于SAP Kyma的订单编排增强介绍 (474)
- 浅谈SAP Cloud for Sales 自动化 (451)
- 一个SAP开发人员的2018年终总结 (376)
- 使用函数BAPISDORDER_GETDETAILEDLIST读取S/4HANA中Sales Order行项目数据 (362)
- 容器,Docker, Kubernetes和Kyma,以及Kyma对SAP的意义 (350)
- SAP C/4HANA与人工智能和增强现实(AR)技术结合的又一个创新案例 (342)
- SAP成都研究院2018年总共87篇技术文章合集 (337)
- 一些SAP Partners能够通过二次开发实现打通C/4HANA和S/4HANA的方法介绍 (334)