SAP C4C基于自定义BO开发的OWL UI,如何实现动态访问控制
My series of Cloud Application Studio Blogs
- How to detect EditMode in an Embedded Component
- Step by step to enable your custom BO with attachment upload functionality
- Step by step to create an Adobe Print form in Cloud application Studio
- How to render PDF which displays picture from the image attachment of your custom BO
- How to get current logged on business user’s employee information and assigned organization unit via ABSL
- How to implement dynamic access control based on custom BO using OWL
- How to make Code List Restriction work when control field and restricted field are not on the same BO
- How to implement custom number range using custom business object
- Two approaches to create Code List in Cloud Studio
- Create Dynamic Code List via Custom Business Object Association
- Step by step to develop Thing Type based navigation and BO Object based navigation
- Put Extension field into embedded component and make it visible in Standard UI
- One possible cause that embedded component fails to display in UI
- Step by step to create HTML Mashup and make it visible in UI
- Step by step to enable Text Collection for your custom BO
- Automatically send an Email notification to line manager via Workflow in Account application
- Step by step to create Object Value Selector in Cloud Application Studio
- Two approaches to fill an UI field with dedicated logic implemented in Cloud Application Studio
- How to execute BO action on multiple selected BO instances in AdvancedListPane
- How to add custom validation logic on mobile phone field in Contact TI
Suppose I have a testBO with the following fields:
import AP.Common.GDT as apCommonGDT;
import AP.FO.BusinessPartner.Global;
businessobject TestBO {
[Label("Agreement ID")] [AlternativeKey] element AgreementID:ID;
[Label("Start Date")] element StartDate:Date;
[Label("Close Date")] element CloseDate:Date;
[Label("Duration")] element Duration:NumberValue;
[Label("IsOverDue")] element IsOverDue:Indicator;
[Label("Quantity")] element Quantity: Quantity;
[Label("ProductName")] element ProductName: LANGUAGEINDEPENDENT_EXTENDED_Text;
[Label("DepartmentName")] [Transient] element DepartmentName:LANGUAGEINDEPENDENT_EXTENDED_Text;
[DependentObject(AttachmentFolder)] node Attachment;
}
And here is some test data displayed in OWL:
Now I would like to achieve the dynamic access control below: Suppose the currently logged on user has been assigned to an organization unit which is only allowed to sell product with name “Laptop”, then this business user SHOULD ONLY see those entries whose value in ProductName equals to Laptop as well. That is to say, the last two entries in above picture with ProductName Monitor should be filtered out.
How the restriction that only Laptop is allowed to sell for employees within a given Organization Unit
For demonstration purpose I just reuse the standard field “Department Name” to store the name of sellable product.
And I assign myself to this organization unit, which means Employee Jerry Wang is only allowed to sell Laptop.
Now I implement this dynamic access control into a new OWL named TestBORestricted_OWL.
Below is the achievement: I have put this new OWL into a new tab in Thing Inspector and once launched, only entries whose ProductName equal to Laptop are displayed. Other entries are filtered out due to the fact that this employee is not allowed to sell them.
Implementation Detail
Here below is step by step implementation detail: (1) Create an AfterLoading event in TestBO with mass enabled checkbox unselected,
And implement the following ABSL code to fill the transient field with product name which is allowed to sell for current logged on user.
import ABSL;
import AP.PC.IdentityManagement.Global;
import AP.FO.BusinessPartner.Global;
var queryByIdentityUUID = Identity.QueryByElements;
var queryByIdentityUUIDParameter = queryByIdentityUUID.CreateSelectionParams();
var queryByEmployeeBPUUID = Employee.QueryByIdentification;
var queryByEmployeeBPUUIDParameter = queryByEmployeeBPUUID.CreateSelectionParams();
if ( this.DepartmentName.IsInitial()){
var id = Context.GetCurrentIdentityUUID().content;
queryByIdentityUUIDParameter.Add( queryByIdentityUUID.UUID.content, "I", "EQ", id.ToString() );
var result = queryByIdentityUUID.Execute(queryByIdentityUUIDParameter);
var first = result.GetFirst(); // points to identity instance
var person = first.Person;
var bpUUId = person.UUID.content;
queryByEmployeeBPUUIDParameter.Add( queryByEmployeeBPUUID.UUID.content, "I", "EQ", bpUUId.ToString());
var employeeQueryResult = queryByEmployeeBPUUID.Execute(queryByEmployeeBPUUIDParameter);
var EmployeeQueryResultCurrent = employeeQueryResult.GetFirst();
if( EmployeeQueryResultCurrent.OrganisationalUnitAssignment.Count() > 0 ){
var assignedOrg = EmployeeQueryResultCurrent.OrganisationalUnitAssignment.GetFirst();
var org = assignedOrg.ToRoot;
// readOnly in AfterLoading event
this.DepartmentName = org.NameAndAddress.AddressSnapshot.NameSuitableForLogonLanguage.GetFirst().Name.SecondLineName;
}
}
(2) In new TestBORestricted_OWL, create a new field ProductName under search structure SearchParameters.
Bind the query to QueryByElements modelled in TestBO and bind the query parameter ProductName to the field ProductName under SearchParameters.
Create a new inport and bind the parameter to the field mentioned above as well.
(3) Create a new outport in Thing Inspector, bind the parameter productName with the transient field DepartmentName filled in step 1.
Create a new tab in Thing Inspector and drag the new OWL into it. Click Bind button:
Bind the parameter of outport defined in TI with the one in inport of new OWL.
With all the steps above done, the sellable product name calculated by ABSL is passed from TI to new OWL via parameter passing during navigation, and could be considered during the query of new OWL is executed. As a result the restriction takes effect due to this ProductName search parameter.
- Android打包遇到的那些坑
- 生信人写程序1. Perl语言模板及配置
- linux中压缩与解压缩命令小结
- java arrays类学习
- 如何使用带有Dropout的LSTM网络进行时间序列预测
- 生信人写程序2. Editplus添加Perl, Shell, R, markdown模板和语法高亮
- Rfam 12.0+本地使用 (最新版教程)
- 宝马汽车安全漏洞详解:古有伯乐识良驹,今有黑客擒宝马
- string.length()与-1比较为什么会出现匪夷所思的结果
- css模块化及CSS Modules使用详解
- 使用OpenCV,Python和模板匹配来播放“Waldo在哪里?”
- C++ 字符串分割
- 算法笔记之排序
- java中String类学习
- JavaScript 教程
- JavaScript 编辑工具
- JavaScript 与HTML
- JavaScript 与Java
- JavaScript 数据结构
- JavaScript 基本数据类型
- JavaScript 特殊数据类型
- JavaScript 运算符
- JavaScript typeof 运算符
- JavaScript 表达式
- JavaScript 类型转换
- JavaScript 基本语法
- JavaScript 注释
- Javascript 基本处理流程
- Javascript 选择结构
- Javascript if 语句
- Javascript if 语句的嵌套
- Javascript switch 语句
- Javascript 循环结构
- Javascript 循环结构实例
- Javascript 跳转语句
- Javascript 控制语句总结
- Javascript 函数介绍
- Javascript 函数的定义
- Javascript 函数调用
- Javascript 几种特殊的函数
- JavaScript 内置函数简介
- Javascript eval() 函数
- Javascript isFinite() 函数
- Javascript isNaN() 函数
- parseInt() 与 parseFloat()
- escape() 与 unescape()
- Javascript 字符串介绍
- Javascript length属性
- javascript 字符串函数
- Javascript 日期对象简介
- Javascript 日期对象用途
- Date 对象属性和方法
- Javascript 数组是什么
- Javascript 创建数组
- Javascript 数组赋值与取值
- Javascript 数组属性和方法
- PHP二维索引数组的遍历实例分析【2种方式】
- Selenium及python实现滚动操作多种方法
- PHP使用JPGRAPH制作圆柱图的方法详解
- PHP 实现超简单的SESSION与COOKIE登录验证功能示例
- PHP 图像处理与SESSION制作超简单验证码的方法示例
- 简述PHP7.4 新特性和废弃的功能
- laravel5.1框架下的批量赋值实现方法分析
- Laravel框架环境与配置操作实例分析
- 记Laravel调用Gin接口调用formData上传文件的实现方法
- Laravel框架视图和模型操作方法分析
- 接口测试框架实战(六) | 配置的数据驱动
- PHP连续签到功能实现方法详解
- PHP实现发送微博消息功能完整示例
- php实现快速对二维数组某一列进行组装的方法小结
- PHP实现提取多维数组指定一列的方法总结