CRM and CX Blogs by Members
Find insights on SAP customer relationship management and customer experience products in blog posts from community members. Post your own perspective today!
cancel
Showing results for 
Search instead for 
Did you mean: 
I want to show you how to display object's related attachments with Odata functionality. If we want to show related attachments of the objects ( for example: showing attachments of customer’s opportunities on customer ,  showing  attachments of child account in parent accounts  ,  showing attachments of subtickets on main tickets or etc... ) , Odata functionality is a good choice with the many advantages it provides. We don’t need to copy and add attachments to another bo or we don’t need to think newly added and deleted attachments !

For my example , ı wanted to show attachments of customer’s opportunities on customer business object.For this purpose , ı followed step by step as below:

 

1)Creating custom business object , necessary fields and actions (clear,update attachments).


   Since we will make a new embedded component in the account , we choose ‘AccountID’ as a key. For attachments fields  (Attachment name,Process type,Odata link,Category code) we created a node Attachments(ID,UUID,Name fields for Opportunities ID,UUID,Name). And we added clear and update actions so that attachments are updated every time the EC is opened.

 

2)Filling ClearAttachments and UpdateAttachments actions for update related attachments.


   Firstly , we need clear attachments to update current attachments in custom business object.


   In the UpdateAttachments , firstly we find the customer’s opportunities with the help of query. Then for each opportunity we return in the attachments. For each attachment we fill the necessary fields of our custom objects with the opportunities attachment’s field.The important point is that if the attachment category code equal “3” (WebUri) , we can take the link directly.But if the attachment category code equal “2” (LocalFile) , we need to arrange Odata link. We can check the odata link in the “Odata Service Explorer” under the “Administrator”.

For my ex: https://myxxxxxx.crm.ondemand.com/sap/c4c/odata-sso/v1/c4codataapi/OpportunityCollection('oppt.UUID'...

For Service Request: https://myxxxxxx.crm.ondemand.com/sap/c4c/odata-sso/v1/c4codataapi/ServiceRequestCollection('SR.UUID...

Etc...

After filling all fields we create record our Attachment node and everything is done in the actions. Now we can create embeded component for customer business object.

 

3)Creating Embeded Component For Related Attachments Tab.

Firstly , we arrange the necessary binding in the data model of embeded component.


   Then we put the necessary fields to designer.For open attachments we make the “AttachName” as a link and put its onClick to new event handler with name “OpenLink”.


   As a next step , we add new inport in the controller and fill necessary inport data in the data model.Also we give the new event handler as a name of “Init”.


   After that , we need to set our event handlers (Init and OpenLink). In the Init event as a first we need to read our custom business object with account id that comes from inport.If there is no record we should create.After creation new record , now we can call our actions respectively (first ClearAttachments then UpdateAttachments).






   Then in the “OpenLink” action , it is enough to use OpenLink type as below.But we should give the Link field that fill in the action as a bind.So everything is done in the Embeded Component.


4)Adding EC to standart screen.

Now , we are in the last step. Finally we need to add new custom embeded component to standart customer TI screen (COD_Account_TI). In the TI screen we click to “Add Embeded Component To Pane” , select our EC  and then we make necessary outport-inport binding as shown below.


 

Now all that’s left is to check and test our new EC on the frontend.


   When we click the attachment name , it downloads and opens attachment via Odata functionality 😊.


   As a conclusion , If we want to see the related attachments, using the Odata functionality is a useful option.The most important point in our work is to find the Odata link from which we will get the attachment with the help of 'Odata Service Explorer'.After getting link , there are no hard work as I explain above.

If you have any questions, please ask in the question section below or directly my personal accounts. Thank you.

Best Regards.

Onur Yurt

 

 
2 Comments