赋予权限
首先要在设置中心给entity
设置可read
权限,把权限规则分配给用户组Web Role
用户登陆之后可以调用的数据
{{user.fullname}} //用户姓名
{{user.id}} == {{user.contactid}} //用户unid
{{user.roles}} //用户网络角色
使用fetchxml调取数据
注意:调取数据之前需要在Entity Permissions里面设置对应表的read权限
1.取出前三条
{%fetchxml get_work_information%}
<fetch mapping ='logical'count ='3'> //调用前三条数据
<entity name ='cr012_mcemployeeworkinfomation'> // name是entity`的逻辑名字。
<attribute name ='cr012_employeeid'alias ='employeeid'/> //别名重写变量名
</ entity>
</ fetch>
{%endfetchxml%}
{%Assign work_data = get_work_information.results.entities%} //数据调用
{{work_data.size}}
{%for work_data%中的项目}
<h4> {{ite.employeeid}} </ h4>
{%endfor%}
attribute
代表你要取的数据项,类似选择name,id
,....中的名称,id,取回可通过别名进行调用输出。仅在attribute定义的属性才能收回并调用,如果想全部调用,不设置attribute
类似select *
,使用<all-attributes> </ all-attributes>
替代
2.条件筛选
{% assign usr= entities.contact[user.id] %}
//usr.cr012_systemid 自定义的system_ID
{% fetchxml get_work_information %}
<fetch mapping="logical">
<entity name="cr012_mcemployeeworkinfomation"> //name 是实体的逻辑名字
<filter type='and'> //过滤字段,类似where 。。。
<condition attribute='cr012_systemid' operator='eq' value='{{usr.cr012_systemid}}' /> //eq为== ne为!= cr012_systemid为查找项
</filter>
</entity>
</fetch>
{% endfetchxml %}
{% assign work_data = get_work_information.results.entities %}
{{work_data.size}} //统计数据有几条
{%for ite in work_data%}
<h4> {{ite.cr012_employeeid}}</h4>
{%endfor%}
可以使用attribute指定数据项,不设置attribute
类似select *
,不可使用<all-attributes> </all-attributes>
,会导致filter失效