CSOM - Multiple lines of Text field value

Manokaran, Murugesan (Muru) 22 Reputation points
2024-12-04T18:12:16.41+00:00

having hard time to get the Multiple Lines of text field value using CSOM.

any help?

SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
3,448 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Ling Zhou_MSFT 23,035 Reputation points Microsoft External Staff
    2024-12-05T01:56:23.8566667+00:00

    Hi @Manokaran, Murugesan (Muru),

    Thanks for reaching out to us. We are very pleased to support you.

    According to the information you provided and the research I have done, I may understand that you want to get the Multiple Lines of text field value using CSOM. If there is anything wrong, please correct me.

    If there are no problems, attached here are two examples of using CSOM in either C# or PowerShell to get multiple lines of text.

    C#:

    using Microsoft.SharePoint.Client;
    
    // Set up the context
    ClientContext context = new ClientContext("https://yoursharepointsite");
    List list = context.Web.Lists.GetByTitle("YourListName");
    
    // Retrieve the list item
    ListItem item = list.GetItemById(1); // Replace with your item ID
    context.Load(item);
    context.ExecuteQuery();
    
    // Access the Multiple Lines of Text field value
    string multilineTextValue = item["YourFieldName"].ToString();
    Console.WriteLine(multilineTextValue);
    

    PowerShell:

    # Load the CSOM assemblies
    Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
    Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
    
    # Set up the context
    $siteUrl = "https://yoursharepointsite"
    $ctx = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl)
    $credentials = Get-Credential
    $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($credentials.UserName, $credentials.Password)
    
    # Retrieve the list item
    $list = $ctx.Web.Lists.GetByTitle("YourListName")
    $item = $list.GetItemById(1) # Replace with your item ID
    $ctx.Load($item)
    $ctx.ExecuteQuery()
    
    # Access the Multiple Lines of Text field value
    $multilineTextValue = $item["YourFieldName"]
    Write-Output $multilineTextValue
    

    If you have any questions, please do not hesitate to contact me. Moreover, if the issue can be fixed successfully, please click "Accept Answer" so that we can better archive the case and the other community members who are suffering the same issue can benefit from it.

    Your kind contribution is much appreciated.


  2. Manokaran, Murugesan (Muru) 22 Reputation points
    2024-12-10T14:46:23.54+00:00

    sorry for the delay.

    recommended approach worked as expected.

    Thanks


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.