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: 
mariusz_jurcz
Participant

Introduction


This blog post provides guide how the list of "from" providers can be restricted.  This approach should help when couple of departments are present in one tenant and people from those departments should not use providers, which they don't supposed to use it. C4C does not provide Code List Restriction or any adaptation changes options in order to restrict access to this content. However it's possible to implement custom BADI in SAP Cloud Application Studio.

Email channels, SMS messages channels and social channels are supported.

 

In this example I will restrict "from" providers based on business role of currently logged user.

Steps for custom solution



  1. I created new solution and added new item of type Enhancement Implementation:



Adding new item in solution


 

2.The values should be chosen like in the screenshot below:


Parameters for BADI


 

The item with extension *.enht should appear in Solution Explorer. After extented this file, it has to have script with following name:

RESTRICT_FROM_ADDRESS.absl

 

Here is example implementation of this script:
/*
Add your SAP Business ByDesign scripting language implementation for:
Enhancement Option: RestrictFromAddress
Operation: RESTRICT_FROM_ADDRESS

Script file signature
----------------------------
Parameter: InputData of type SocialMediaActivityProviderRestrictFromBadiInput
Returns: SocialMediaActivityProviderRestrictFromBadiOutput

Note:
- To use code completion, press CTRL+J.
*/
import AP.FO.Activity.Global;
import AP.PC.IdentityManagement.Global;
import ABSL;

var result : SocialMediaActivityProviderRestrictFromBadiOutput;
var listOfAllowedProviders : SocialMediaActivityProviderRestrictFromBadiOutput.SocialMediaActivityProviderIDList;


var identityUUID = Context.GetCurrentIdentityUUID();
var roles = IdentityUtilities.GetAssignedBusinessRoles(identityUUID).BusinessRoles;


var query = SocialMediaActivityProvider.QueryByElements;
var praram = query.CreateSelectionParams();
praram.Add(query.ID.content, "I", "NE", "");
var elements = query.Execute(praram);

if(roles.Where(role => role.content == "Put your role ID here").Count() > 0){
var listOfProvidersNames = elements.Where(x=>(x.AccountName == "put your channel ID here" || x.AccountName == "put your channel ID here"));

foreach(var item in listOfProvidersNames){

listOfAllowedProviders.SocialMediaActivityProviderID = item.ID.content;
result.SocialMediaActivityProviderIDList.Add(listOfAllowedProviders);
}
}
else{

foreach(var item in elements){

listOfAllowedProviders.SocialMediaActivityProviderID = item.ID.content;
result.SocialMediaActivityProviderIDList.Add(listOfAllowedProviders);
}

}

return result;

 

In "Put your role ID here" and "put your channel ID here", corresponding ID's must be substituted with values presented in tenant.

Examples of working:

Before implementation:


Selection channel "from" before implementation


After implementation:


Selection channel "from" after implementation



Description of script


Basically script takes llist of roles from logged user. In the next step querry gets executed to get list of all channels by ID. Then there are lines of code, which assign channels to business role, so logged-in user can choose only providers based on script. If user don't have role in "Put your role here", the "else" part of script gets executed which grant access to all available channels.

 

Summary


I prepared simple steps on how restriction of "from" address can be done in very simple way. Obviously this is only proof of concept, every customer or partner may have other requirements. This code can improved and refactor, but I think it's readable to get the idea.

It is worth to mention, that after activation of custom BADI in order to disable it, it has to be deleted. At least it works in that way in my tenant.

I hope, that this short blog post can help with development and customization in other C4C tenants.

Thank you for reading and please like and share this blog post.

If you have any question, don't hesitate to comment.

 

Best regards,

Mariusz Jurcz
6 Comments