Community
Showing results for 
Search instead for 
Do you mean 
Reply

Notes 'NoteText' returning string with unwanted data, am I doing something wrong or is this just what is returned?

Accepted Solution Solved
Copper Super Contributor
Posts: 28
Country: Canada
Accepted Solution

Notes 'NoteText' returning string with unwanted data, am I doing something wrong or is this just what is returned?

[ Edited ]

I get a note like so: 

 

NoteList nl = act.getNotes(con);

foreach (Note n in nl) {
    Response.Write(n.NoteText);
}

And it returns a string with the expected text except, there is a ton of other text surrounding it, like so:

 

{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Microsoft Sans Serif;}}
\viewkind4\uc1\pard\f0\fs17 test\par
}

Am I doing something wrong? Is this how it's expected to return, if so, is there a standard method of retrieving just the text that was input in the note? Will I have to parse through it manually (regular expression or what not)? Is it a bug? 

 

For clarification the "test" is the text originally input in the note text field in ACT (resides near the end of the string, between the "fs17" and the "\par"

 

Any help would greatly appreciated, thanks.

 

 


Accepted Solutions
Solution
Accepted by topic author 2gen
‎09-25-2015 03:20 AM
Silver Super Contributor
Posts: 2,328
Country: USA

Re: Notes 'NoteText' returning string with unwanted data, am I doing something wrong or is this just what is returned?

It is RTF formatting.  You just need to create a rich text box and then use it to change the content from rtf to text.

 

richtextbox rtb;

rtb.rtf = xxx

string s = rtb.text

 

Stan


If you would like to get more out of ACT! you can find an ACT! Certified Consultant near you by going to:www.act.com/acc.
-------------------------------------------------------------------------------------
Stan Smith
ACT! Certified Consultant
ADS Programming Services, Inc.
(205) 222-1661
www.adsprogramming.com
www.actwebhosting.com
Click Here to Purchase Act!

View solution in original post


All Replies
Solution
Accepted by topic author 2gen
‎09-25-2015 03:20 AM
Silver Super Contributor
Posts: 2,328
Country: USA

Re: Notes 'NoteText' returning string with unwanted data, am I doing something wrong or is this just what is returned?

It is RTF formatting.  You just need to create a rich text box and then use it to change the content from rtf to text.

 

richtextbox rtb;

rtb.rtf = xxx

string s = rtb.text

 

Stan


If you would like to get more out of ACT! you can find an ACT! Certified Consultant near you by going to:www.act.com/acc.
-------------------------------------------------------------------------------------
Stan Smith
ACT! Certified Consultant
ADS Programming Services, Inc.
(205) 222-1661
www.adsprogramming.com
www.actwebhosting.com
Click Here to Purchase Act!
Copper Super Contributor
Posts: 28
Country: Canada

Re: Notes 'NoteText' returning string with unwanted data, am I doing something wrong or is this just what is returned?

Thanks!.....why doesn't this just come out as normal text? Is there a reason for that? I mean I feel like it should just come out as the text of the note....
Silver Super Contributor
Posts: 2,328
Country: USA

Re: Notes 'NoteText' returning string with unwanted data, am I doing something wrong or is this just what is returned?

Because the note field supports standard text and rtf both.  The SDK could have returned it without the rtf formatting but depending on what you were trying to do with the note the rtf formatting might come in handy.

 

Stan


If you would like to get more out of ACT! you can find an ACT! Certified Consultant near you by going to:www.act.com/acc.
-------------------------------------------------------------------------------------
Stan Smith
ACT! Certified Consultant
ADS Programming Services, Inc.
(205) 222-1661
www.adsprogramming.com
www.actwebhosting.com
Click Here to Purchase Act!
Copper Super Contributor
Posts: 28
Country: Canada

Re: Notes 'NoteText' returning string with unwanted data, am I doing something wrong or is this just what is returned?

[ Edited ]

Give the option to do both? I mean, I guess one can only hope.

 

Anywys as it stands, I've just run into an issue. Apparently I am unable to create a RichTextBox as it seems there is no class to do so?

 

Capture.PNG

 

When I right click there's no option to "Resolve" either:

 

Capture2.PNG

 

RichTextBox is a standard class of the C# is it not?

 

Thanks again for your help Smiley Very Happy

 

EDIT: IT'S BECAUSE I'M USING A WEB PROJECT

Nickel Contributor
Posts: 175
Country: USA

Re: Notes 'NoteText' returning string with unwanted data, am I doing something wrong or is this just what is returned?

[ Edited ]

If you need any sort of formatting (bold, italic, underline, tables, bullets, etc.) saved in the note, it has to be stored somehow. RTF (maybe even HTML) is the most common way of doing that. It is pretty easily converted in code, like Stan showed. Would it be nice to have a .NoteTextWithoutFormatting property? Certainly, but it's a nice to have, not a need to have.

 

Edit: If you have an add-in, you'll most likely need to reference in System.Windows.Forms, if I recall the namespace properly. You can check to see where the RichTextBox is located (namespace) on MSDN, then just reference that DLL into your project.

Copper Super Contributor
Posts: 28
Country: Canada

Re: Notes 'NoteText' returning string with unwanted data, am I doing something wrong or is this just what is returned?

[ Edited ]

Yeah I can undestand that. It's easier to go down from something RTF than losing all that formatting. It WOULD be nice to be able to get the text of the note as well as I think it's poor practice to have to create an object specifcally designed for display, just as a placeholder to extract the data you want. That being said, I know it's not that big of an issue

Silver Super Contributor
Posts: 2,328
Country: USA

Re: Notes 'NoteText' returning string with unwanted data, am I doing something wrong or is this just what is returned?

You probably need to add a form class to your program.  Off the top of my head I think you can add act.shared.windows.forms.dll.  There are lots of other ways to strip off the rtf encoding but all of them either mean adding another dll or writing your own code.  The way I showed you is the way I do it.  Admittedly it isn't the most efficient to run but it is one of the most efficient to write!

 

Stan


If you would like to get more out of ACT! you can find an ACT! Certified Consultant near you by going to:www.act.com/acc.
-------------------------------------------------------------------------------------
Stan Smith
ACT! Certified Consultant
ADS Programming Services, Inc.
(205) 222-1661
www.adsprogramming.com
www.actwebhosting.com
Click Here to Purchase Act!
Copper Super Contributor
Posts: 28
Country: Canada

Re: Notes 'NoteText' returning string with unwanted data, am I doing something wrong or is this just what is returned?

[ Edited ]

Yeah I was thinking of some sort of regular expression. It's because I'm using a web application that I can't import anything from System.Windows.....so it looks like I'll be going the regex path...hah.

Copper Super Contributor
Posts: 86
Country: United_Kingdom

Re: Notes 'NoteText' returning string with unwanted data, am I doing something wrong or is this just what is returned?

Hi guys,

 

Seems that you've already gotten to the bottom of this one, but I wanted to confirm that Stan is right about why it shows the extra text.

There's no way to request just the text through the SDK so you do have to parse it yourself.

I would also recommend using Stan's method which should be fine as long as you dispose afterwards and aren't converting 10,000 lines of text.

Not sure why you can't reference the correct assembly, you can definitely do that in a web project.

I personally find regex a nightmare for this because you can't always guarantee the structure of the string so it's hard to find the start of the actual text.

 

Kind regards,

 

Sam.

____________________________________________________________

Unfortunately I no longer work for Swiftpage International. Please do not send any queries to this account.