创建具有特殊字符和不同语言的计算列. [英] Create calculated column with special character and different language.

查看:71
本文介绍了创建具有特殊字符和不同语言的计算列.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在尝试下面的代码使用powershell创建计算列.我有两列具有特殊字符和不同语言的列.

请注意,使用我的代码可以创建这些列,因为其中包含特殊字符和不同的语言.

任何人都可以向我提供有关如何创建列的解决方案.

公式:

p公式='= IF([3.nderung]";"3; IF([2.nderung]";"2; IF([1.nderung]" ]"";;; 1; 0)))';

$ formula ='= IF([Masnahme状态] ="Im计划"; 3; IF([Masnahme状态] ="Fokus erforderlich"; 2; IF([Masnahme状态] ="Neuplannung erforderlich"); ; 1; 2)))';

代码:

  $ FieldSchema =<字段类型='计算得出的ID'='{$ FieldID}'DisplayName ='$ displayName'Name ='$ fieldName'Description ='$ description'ResultType ='$ ResultType' ReadOnly ='TRUE'Decimals ='$ decimals'< Formula"" + $ formula +</Formula>< FieldRefs> $ FieldRefXML</FieldRefs>//Field""
$ FieldSchema;
$ NewField = $ List.Fields.AddFieldAsXml($ FieldSchema,$ True,[Microsoft.SharePoint.Client.AddFieldOptions] :: AddFieldInternalNameHint);                        
$ clientContext.Load($ NewField);            
$ clientContext.ExecuteQuery();

将列添加到列表时出错!异常调用"ExecuteQuery";带有"0"参数:该公式包含语法错误或不受支持."


  • 谢谢

    Harish Patil


    解决方案

    请尝试转义字符<>如下所示,是我在本地测试的示例.

    提示:您可以在UI中创建计算列首先,然后由SharePoint Manager监视架构,这将有助于进行故障排除.

     


    SiteURL ="http://sp:12002/sites/Team/"


    ListTitle = "TestList"; #添加对SharePoint客户端程序集的引用并验证到Office 365站点-CSOM必需 添加类型-路径"C:\ Program Files \ Common Files \ Microsoft Shared \ Web服务器扩展\ 15 \ ISAPI \ Microsoft.SharePoint.Client.dll" 添加类型-路径"C:\ Program Files \ Common Files \ Microsoft Shared \ Web服务器扩展\ 15 \ ISAPI \ Microsoft.SharePoint.Client.Runtime.dll" #Bind to site collection


    Hi All,

    I am trying below code creating calculated column with powershell. I have two columns with special character and different language.

    With my code I am note able create those columns because it contain special character and different language.

    Can anyone please provide me solution for how to create column.

    Formula:

    $formula = '=IF([3. Änderung]<>"";3;IF([2. Änderung]<>"";2;IF([1. Änderung]<>"";1;0)))';

    $formula = '=IF([Status der Maßnahme]="Im Plan";3;IF([Status der Maßnahme]="Fokus erforderlich";2;IF([Status der Maßnahme]="Neuplannung erforderlich";1;2)))';

    Code:

     $FieldSchema = "<Field Type='Calculated' ID='{$FieldID}' DisplayName='$displayName' Name='$fieldName' Description='$description' ResultType='$ResultType' ReadOnly='TRUE' Decimals='$decimals'><Formula>"+$formula+"</Formula><FieldRefs>$FieldRefXML</FieldRefs></Field>";
    $FieldSchema;
    $NewField = $List.Fields.AddFieldAsXml($FieldSchema,$True,[Microsoft.SharePoint.Client.AddFieldOptions]::AddFieldInternalNameHint);                        
    $clientContext.Load($NewField);            
    $clientContext.ExecuteQuery();

    Error:

    1. Error Adding Column to List! Exception calling "ExecuteQuery" with "0" argument(s): "The formula contains a syntax error or is not supported."
    2. Error Adding Column to List! Exception calling "ExecuteQuery" with "0" argument(s): "Name cannot begin with the '>' character, hexadecimal value 0x3E. Line 1, position 210."


    Thanks,

    Harish Patil


    解决方案

    Hi,

    Try to escape the character <> as below sample which I tested in my local.

    Tip: you may create a calculated column in UI first and then monitor the schema by SharePoint manager, this would help for troubleshooting.


    SiteURL = "http://sp:12002/sites/Team/"


    ListTitle = "TestList" #Add references to SharePoint client assemblies and authenticate to Office 365 site - required for CSOM Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll" Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll" #Bind to site collection


    这篇关于创建具有特殊字符和不同语言的计算列.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆