So this is my first post on this dynamics AX blog of mine. I'm going to use this to keep track of the little programming solutions I develop. Maybe it will help someone else too. Who knows?
My customer was having problems with a report showing the delivery address in excel. When a new line character is reached, it moves to another line. This made the excel format untenable for our 3rd party vendor that needed the data. So I wrote this code on the report to strip the new line character out and replace it with a space.
display str DeliveryStreet()
{
TextBuffer txt = new TextBuffer();
;
txt.setText(dataSource.DeliveryStreet);
txt.replace('\n',' ');
dataSource.DeliveryStreet = txt.getText();
return(dataSource.DeliveryStreet);
}
The DeliveryStreet field on the report calls this method instead of calling the field on the datasource.
Thanks! I really need this :)
ReplyDeleteThanks for reading! I'm glad it helped.
DeleteThanks a lot this help me when transfer address in to csv File
ReplyDeleteYes, we had the same problem. Sometimes it's something small that causes you a lot of trouble. Good luck!
DeleteYou could use the function strRem.
ReplyDeletestrRem(dataSource.DeliveryStreet, '\n')
Yes, that will work to remove the new line character, but if you want to replace the new line character with a space, you can use my code above. If you don't replace it with a space, you could end up with words concatenated when you don't wish them to be.
DeleteHI amber,
ReplyDeletethanks your blog helped me
I'm glad!
DeleteThanks.This is Himanshu Sinha from India. I need to append newline character to text buffer, please give me some suggestion.
ReplyDeleteThanks in advance
You should be able to do something simple like:
DeleteNewText = text + '\n';
Thanks
ReplyDeleteYou're welcome!
DeleteThanks it helped me
ReplyDeleteI'm glad it was helpful to you!
DeleteWow! Totally fixed a problem I was having passing a web template. Thanks!
ReplyDeleteI'm glad it is useful in many ways!
Delete