Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
victorsilva
Product and Topic Expert
Product and Topic Expert
0 Kudos
Hello Community,

 

C4C offline has some restrictions if compared to the online app. Because of that, you may need to change your custom code in the Studio. One good example is on the validations that are performed on the Studio and will be executed only when user syncs the data to server, in this case you may not want to block saving for example.

On 1711 version, there is no available field/function to identify from the Studio if script is running from a synchronization or while online.

 

In this blog I describe the step-by-step to verify if the instance was created while offline by using an Embedded Component on Quick Create.

This development was done on Activity BO from C4C.

 

 

1. Create an extension field on the BO to indicate if instance was created online or offline

element CreatedOfflineActivity: Indicator = true;

 

2. Create a dummy Embedded Component

Embedded Components just run while online. This EC will be used on QC to flag CreatedOfflineActivity as false and won't have any UI component to be invisible for the user.

* An existing EC could be used to avoid development effort and improve performance.

2.1. On DataModel

2.1.1. Create field to be bound in EC Inport (Root-INPORT-ActivityUUID)

2.1.2. Create field bound with UUID(Root-Activity-UUID)

2.1.3. Create field bound with extension field CreatedOfflineActivity (Root-Activity-CreatedOfflineActivity)



 

2.2. On Controller

2.2.1.Create an inport to receive the UUID

2.2.2. Flag inport to be fired on initialization

2.2.3. Set OnFire event



2.2.4. On OnFire event, add BOOperation to read your instance



2.2.5. On OnFire event, add DataOperation to set CreatedOfflineActivity to false



 

3. Add Embedded Component to Quick Create

3.1. Select anchor from Extensibility Explorer.

3.2. Click on Add embedded component to pane

3.3. Select your EC

3.4. Bind QC Inport with EC Outport



 

 

Now you can use the field to change your validations, reporting, etc.

 

Cheers!
1 Comment