Forum Discussion

Justin Liu's avatar
Mar 03, 2017

SharePoint CSOM field.TitleResource.GetValueForUICulture return null value

Hi guys

recently, I am working on the sharepoint online multi languages function.

I refered this link

https://blogs.msdn.microsoft.com/vesku/2014/03/20/office365-multilingual-content-types-site-columns-and-other-site-elements/

But after I set a field's title resource value by SetValueForUICulture, I can not get it by GetValueForUICulture. It returns null value result.

below is my sample code.

using (ClientContext context = CreateContext(targetSite, username, password))
                {
                    Web web = context.Web;
                    List list = web.Lists.GetByTitle("Documents");
                    context.Load(web);
                    context.Load(list);
                    Field field = list.Fields.GetByTitle("test");
                    context.Load(field, f => f.TitleResource);
                    context.ExecuteQuery();
                    ClientResult<string> result = field.TitleResource.GetValueForUICulture("fr-FR");
                    
                    field.TitleResource.SetValueForUICulture("fr-FR", "测试描述");
                    field.UpdateAndPushChanges(true);
                    context.ExecuteQuery();
                }

Any suggestions will be appreciated.

1 Reply

  • new discovery

    if I execute follow code, I can get the result, it seems that it has one time delay, a bug?

     

    ClientResult<string> result = field.TitleResource.GetValueForUICulture("fr-FR");
    field.TitleResource.SetValueForUICulture("fr-FR", "temp");
    field.UpdateAndPushChanges(true);
    context.ExecuteQuery();
    if (result.Value != null)
    {
    Console.WriteLine(result.Value);
    field.TitleResource.SetValueForUICulture("fr-FR", "测试描述");
    field.UpdateAndPushChanges(true);
    context.ExecuteQuery();
    }

Resources