zoukankan      html  css  js  c++  java
  • SSRS 请求并显示SharePoint人员和组字段

    场景:

    使用Reporting Service请求SharePoint List,该list中包含人员和组字段。要求:只显示人员或组的display name。示例如下:

    项目 参与人员 期望显示
    项目1 张三#contosozhangsan;李四#contosolisi;19;#王五;管理员组 张三;李四;王五;管理员组

    步骤:

    1. 替换";#"成"@@"

    2. 按";"分割成数组,遍历数组,循环取出值

    3. 按"#"分割字符串,取数组第一个值

    4. 按"@@"分割字符串,取数组第二个值

    Public Function GetPersionName(Combined As String) As String
        if (InStr(Combined ,"@@") > 0) Then
            Return Split(Combined,"@@").GetValue(1)
         Else
     if(InStr(Combined ,"#") > 0) Then
       Return  Split(Combined,"#").GetValue(0)
     Else
      Return Combined
     End If
        End If
    End Function
     
    Public Function GetPersionNameStr(Combined As String) As String
     if  (Combined ="") Then
           return ""
     End If
    
      dim returnStr,i
      returnStr= ""
     
     Combined = Replace(Combined,";#","@@")
      if (InStr(Combined ,";") > 0) Then
            for  i = 0 to Split(Combined,";").Length - 1
     dim str = Split(Combined,";").GetValue(i)
     returnStr = returnStr+ GetPersionName(str) + ";"
            next  
            Return returnStr
         Else
            Return GetPersionName(Combined)+";"
       End If
    End Function

    报表字段里插入fx,值等于

    =Code.GetPersionNameStr(Field!参与人员.Value)

    预览。

    P.S.

    在RS中的IIF用起来跟传统的if判断有点不同。IIF不是个表达式,而是个方法,这个方法有3个参数。

    IIF(Condition, ValueIfTrue, ValueIfFalse)

    也就是说,Condition,ValueIfTrue,ValueIfFalse在运行的时候都会执行。如果你想这样玩儿,你就会失望了。

    IIF(
        InStr(Fields!User.Value,";") > 0 
        ,Split(Fields!User.Value,";").GetValue(1)
        ,Fields!User.Value
         )

    不管条件InStr(Fields!User.Value,";") > 0成功与否,Split(Fields!User.Value,";").GetValue(1)都会执行。是不是相当不爽???!!!

  • 相关阅读:
    手把手教你学Git
    服务器上Mysql的安装与配置
    python 5
    python 4
    python 3
    python 2
    区分命令行模式和Python交互模式
    CUDA编程模型之内存管理
    多目标优化算法-NSGA2
    C# ListView 如何添加列标头
  • 原文地址:https://www.cnblogs.com/wpsl5168/p/3144381.html
Copyright © 2011-2022 走看看