Home Orchestrator

Adding Multiple Lines To Data Field

Brad_ZimaBrad_Zima Member Advanced IT Monkey ✭✭✭

I'm currently working on outputting multiple object to the Description field in a work item and was wondering how to insert a newline in between the data points? I've tried the usual `n and `r`n to no avail. Can anyone help me out?

Best Answers

  • Brad_ZimaBrad_Zima Member Advanced IT Monkey ✭✭✭
    edited December 2021 Answer ✓

    I wanted to update anyone who might stumble across this in the future. When I wrote the post I was using a copy of @Adam_Dzyacky's Add-ActionLogEntry function which can be found in the SMLets Exchange connector script. There appears to be some weird conversion going on when passing a string with escaped chars to the function.

    The solution was to use "`r`n" to create a newline when passing to the function. When using direct SMLets I believe @Peter_Miklian's example above should be sufficient.


    Edit: I should specify this isn't the exact answer to the question I had at the time, but it is the second post that comes up when searching for the terms "Powershell newline" in the community so it seemed like a good place to put it.

Answers

  • Peter_MiklianPeter_Miklian Customer Advanced IT Monkey ✭✭✭

    @Brad_Zima this is working fine for me. Make sure you are using the right ` sign.

    Set-SCSMObject -SMObject (Get-SCSMObject -Class (Get-SCSMClass ^System.WorkItem.ServiceRequest$) -Filter "Name -eq 'SRID'") -Property Description -Value "first line`nsecond line`nthird line`t`t`taligned text"
    
  • Brad_ZimaBrad_Zima Member Advanced IT Monkey ✭✭✭

    Unfortunately, I'm using the stock data fields in an Orchestrator runbook and not a Powershell script, or are you saying this will work there as well?

  • Brad_ZimaBrad_Zima Member Advanced IT Monkey ✭✭✭

    Oh man, I had no idea the Expand option was there! I feel kind of dumb for not seeing it before. Only a half-hour into the work day and I've learned something new. Thanks guys!

  • Brad_ZimaBrad_Zima Member Advanced IT Monkey ✭✭✭
    edited December 2021 Answer ✓

    I wanted to update anyone who might stumble across this in the future. When I wrote the post I was using a copy of @Adam_Dzyacky's Add-ActionLogEntry function which can be found in the SMLets Exchange connector script. There appears to be some weird conversion going on when passing a string with escaped chars to the function.

    The solution was to use "`r`n" to create a newline when passing to the function. When using direct SMLets I believe @Peter_Miklian's example above should be sufficient.


    Edit: I should specify this isn't the exact answer to the question I had at the time, but it is the second post that comes up when searching for the terms "Powershell newline" in the community so it seemed like a good place to put it.

Sign In or Register to comment.