Removing Special Characters from column values | Community
Skip to main content
Level 2
January 24, 2024
Solved

Removing Special Characters from column values

  • January 24, 2024
  • 3 replies
  • 1178 views

Hi Team,

 

I'm currently retrieving data from an external database table, and one of the columns, named "account number," contains values with special characters, specifically '|', at various positions. My objective is to cleanse these values by removing the pipe '|' character before proceeding with further processing. Could you please guide me on how to accomplish this in ACC V8?

I have attached the snapshot of the code for your reference.

Thank you for your assistance.

Regards,
Ankita Vishe

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by LakshmiPravallika

Hi @ankitav3131 ,

 

Please try by adding this line to your Javascript code and test it.

 

vars.outputText = vars.inputText.replace(/\|/g,"");

logInfo("Output Text "+vars.outputText);

 

Also Please find the link which may be helpful

 

https://stackoverflow.com/questions/29593532/how-to-globally-replace-pipe-symbol-in-string

 

Hope this helps!

 

Regards,

Pravallika.

 

3 replies

LakshmiPravallika
Community Advisor
LakshmiPravallikaCommunity AdvisorAccepted solution
Community Advisor
January 24, 2024

Hi @ankitav3131 ,

 

Please try by adding this line to your Javascript code and test it.

 

vars.outputText = vars.inputText.replace(/\|/g,"");

logInfo("Output Text "+vars.outputText);

 

Also Please find the link which may be helpful

 

https://stackoverflow.com/questions/29593532/how-to-globally-replace-pipe-symbol-in-string

 

Hope this helps!

 

Regards,

Pravallika.

 

isahore
Community Advisor
Community Advisor
January 25, 2024

Hi @ankitav3131,

 

Once you are done eliminating the pipes in the string, you also need to write it back into the temporary schema. You can do so using the xtk.Session.Write method. Something like this should do (haven't tested with your example):

In your queryDef, you also need to select the key field in the select element. Use it in the Write method.

 

xtk.Session.Write(<temp xtkschema="temp:enrich32" _operation="update" key="<yourKeyField>" accTNUM={vars.outputText} />);

 

The above approach will write the updated value into the temp table one by one. You can improve your code and use the WriteCollection method instead of just Write. The syntax varies only a little bit, and you will need to use your for-each loop to create a collection before writing it to the temp table.

 

BR,

Ishan

Sukrity_Wadhwa
Community Manager
Community Manager
March 8, 2024

Hi @ankitav3131,

Were you able to resolve this query with the help of the given solutions or do you still need more help here? Do let us know. In case the given solutions were helpful, then kindly choose the one that helped you the most as the 'Correct Reply'.
Thanks!

Sukrity Wadhwa