Expand my Community achievements bar.

SOLVED

Removing Special Characters from column values

Avatar

Level 2

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

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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.

 

View solution in original post

3 Replies

Avatar

Correct answer by
Community Advisor

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.

 

Avatar

Community Advisor

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

Avatar

Administrator

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