Jithisha Respected Contributor.
Respected Contributor.
373 views

How to add new line while importing text file

Jump to solution

Hi experts,

Please find the below screen shot of sample text file which am using to Import.

Screen_shot_1.JPG

Each source field is separated using tab. For Note History field I have added special character ($*@*$). My requirement is to replace this special character with new line (\n) while importing.

Below is the JavaScript condition which I gave in Advance Tab of Import Wizard to replace special character with \n.

target['action']=source['Notes History'].replace("$*@*$","\n");

But this special character is not replacing with new line.

Below screen shot shows that the special character was not replaced by new line.

Screen_shot_2.JPG

 

Can anyone suggest a method to add new line while importing.

Any suggestion is appreciated.

Thanks,

Jithisha

0 Likes
1 Solution

Accepted Solutions
Highlighted
Super Contributor.. bogart Super Contributor..
Super Contributor..

Re: How to add new line while importing text file

Jump to solution

Hi Jithisha,

just a thought:

In case that the action field is an array (multiline fields are often arrays in SM) you should use split instead of replace...

target['action']=source['Notes History'].split("$*@*$");

Good luck!

Bo 🙂

5 Replies
Carlos_V_SM Acclaimed Contributor.
Acclaimed Contributor.

Re: How to add new line while importing text file

Jump to solution

Hi,

COuld you please share the STR in order to see if I can reproduce it on my OOB system? please exact version too.

Carlos Villalobos R
Customer Support Engineer
If you find that this or any other post resolves your issue, please be sure to mark it as an accepted solution.
If you are satisfied with anyone’s response please remember to give them a KUDOS by clicking on the STAR at the bottom left of the post and show your appreciation.
0 Likes
Jithisha Respected Contributor.
Respected Contributor.

Re: How to add new line while importing text file

Jump to solution

Hi Clarlos,

Could you please tell me what do you mean by STR? 

SM Version :      9.4

 

Thanks & Regards,

Jithisha

0 Likes
Carlos_V_SM Acclaimed Contributor.
Acclaimed Contributor.

Re: How to add new line while importing text file

Jump to solution

Hi,

My apologize, would be the steps to reproduce, the steps i will need to follow.

Carlos Villalobos R
Customer Support Engineer
If you find that this or any other post resolves your issue, please be sure to mark it as an accepted solution.
If you are satisfied with anyone’s response please remember to give them a KUDOS by clicking on the STAR at the bottom left of the post and show your appreciation.
0 Likes
Jithisha Respected Contributor.
Respected Contributor.

Re: How to add new line while importing text file

Jump to solution

Hi Carlos,

SM Version: 9.4

Attached the text file which I used to import.

Steps to reproduce:

  1. Navigate to Database Manager.
  2. Select Text import Wizard from more. Below screen shot shows the same.db.png
  3. Import Wizard appears.importWizard.JPG

    Here select the import CdaxClosIncident.txt file, which I have shared as attachment.

    Select the destination table and File type as shown.

  4. Click search.
  5. Import descriptor list appears. Below is the descriptor which I have created for this import.discriptor.png

    Click Advance Tab.

    javascript.JPG

    Here I have given the JavaScript

    target['action']=source['Notes History'].replace("$*@*$","\n");

    To replace special characters with new line.

  6. Click Test.result.png

    Here you can see that the special character is not getting replaced by newline. 

    Is there any way to replace special character with new line.

Any suggestions are appreciated.

Thanks,

Jithisha

0 Likes
Highlighted
Super Contributor.. bogart Super Contributor..
Super Contributor..

Re: How to add new line while importing text file

Jump to solution

Hi Jithisha,

just a thought:

In case that the action field is an array (multiline fields are often arrays in SM) you should use split instead of replace...

target['action']=source['Notes History'].split("$*@*$");

Good luck!

Bo 🙂

The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.