String operations

Is there a way to perform additional operations on string values?  I need to be able to truncate a string if greater than a certain length and have a value that I need to parse/split into two parts.  How can I best accomplish this?

As an example, if I return the "Author" field from a list item, it returns in the form: "{UserID};#{UserName}".  I don't want to display the UserID value, so I'd need a way to pull just the UserName portion out of the field value.

Have more questions? Submit a request


  • 0
    Matthew McBride

    Do you have an example using the $Expressions.Split function?  I used:

    #set( $authorParts = $Expressions.Split($dataRow.get_item("Author"), ";#") )

    but I can't figure out the correct syntax to render the array elements returned by the Split method.  For instance, $authorParts[0] renders "System.String[[0]".

  • 0
    Fernandes, Denzil

    this works...try it

    #set ( $input = "1a2a1b2b" )
    #set ( $test = $Expressions.Split($input, "1"))

  • 0
    Fernandes, Denzil

    Got it Jeremy.. Check out my solution using DataZoom to read All Web Applications and Their Respective Application Pools..

    The trick was to use $Strings.Format before getting the item in the array...

    #set ( $WebApps = $webApplication.WebService.WebApplications )
    #set ( $Farm = $webApplication.WebService.Farm )
    <span class="ms-vb"> $Farm </span><br>

    #foreach($WebApp in $WebApps)
        <table class="ms-listviewtable" cellpadding="3" cellspacing="0" border="0" width="100%">
          <tr class="ms-viewheadertr">
            <th class="ms-vh2-nofilter">Display Name</th>
            <th class="ms-vh2-nofilter">Application Pool</th>
          <tr class="">
          <tr class="ms-alternating">
            <td class="ms-vb2">$WebApp.DisplayName</td>
     #set ( $WebAppPoolPropertyValue = $Strings.Format("$WebApp.ApplicationPool") )
     #set ( $WebAppPoolName = $Expressions.Split("$WebAppPoolPropertyValue", "="))
            <td class="ms-vb2">$Strings.Format($WebAppPoolName.get(1))<td>
        No lists found


Please sign in to leave a comment.