Commitment Exceptions with Hyperlink

Discussions related to custom development with Select.
tmeisinger
Posts: 74
Joined: Fri Apr 24, 2015 10:33 am

Commitment Exceptions with Hyperlink

Post by tmeisinger »

I would like to dynamically create an Exception with a Hyperlink. It's easy enough to create a new Exception, set the Code and Text. But need to understand how to format the Hyperlink. Help please.
BobRichards
Posts: 1150
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: Commitment Exceptions with Hyperlink

Post by BobRichards »

Please provide a code example of what you have so we have a good starting place.
Bob Richards, Senior Software Developer, SoftPro
tmeisinger
Posts: 74
Joined: Fri Apr 24, 2015 10:33 am

Re: Commitment Exceptions with Hyperlink

Post by tmeisinger »

I have these Exceptions coming over from an internal system via a Database Read, I've attempted to mock this up in C# for you, but it is actually written in VB so there might be some slight syntax problems, I hope it makes since...

Within the "exceptionText", I would like to know the format of the hyperlink. Doesn't appear that I can use <a href="...">text</a>?

Code: Select all

IOrder Order = OrderStore.OpenOrder(search, false);
object OrderObject = Order;
object TitleObject = Order("Title");
object CommitmentObject = TitleObject.Commitments(0);

...Stored Procedure Stuff...

while (reader.Read()) {
  object ExceptionObject = Order.CreateNew("Exception");
  ExceptionObject.Code = (7 + Convert.ToInt32(reader["exceptionNumber"])).ToString().PadLeft(2, "0");
  ExceptionObject.Text = reader["exceptionText"];

  CommitmentObject.Exceptions.@add(ExceptionObject);
}
BobRichards
Posts: 1150
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: Commitment Exceptions with Hyperlink

Post by BobRichards »

The text is the RTF content from a RichTextBox. One way to do it is to instantiate a RTB control then insert your text. Be sure to reuse the control as much as possible since control creation is expensive.

For a library that enables you to insert hyperlinks, see the RichTextBoxEx class in the CodeProject article Links with arbitrary text in a RichTextBox.
Bob Richards, Senior Software Developer, SoftPro
tmeisinger
Posts: 74
Joined: Fri Apr 24, 2015 10:33 am

Re: Commitment Exceptions with Hyperlink

Post by tmeisinger »

OK, I downloaded the RichTextBoxLinks library, compiled, referenced and created a RTB with a Link and it didn't quite work via the API.
My abbreviated code:

Code: Select all

Dim ExceptionObject As Object = Order.CreateNew("Exception")
ExceptionObject.Code = (7 + CInt(readerExceptions("exceptionNumber"))).ToString().PadLeft(2, "0")
driRTB.SelectedText = readerExceptions("exceptionText") + "  Note: "
driRTB.InsertLink("View Doc", "<http://www.drititle.com/addressdocs/16753/Plat-98E.pdf>")
ExceptionObject.Text = driRTB.Rtf
I ended up with the following in the Phrase table:

Code: Select all

{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Microsoft Sans Serif;}}
\viewkind4\uc1\pard\f0\fs17 Easements contained in the Plat and Dedication of 1000 DODGE BUILDING CONDO PROP REG*, filed August 03, 2015, as Document No. 11111111.  Note: View Doc\v #<http://www.drititle.com/addressdocs/16753/Plat-98E.pdf>\v0\par}
I look at an Exception created via the app in the Phrase table, and it looks like this:

Code: Select all

{\rtf1\ansi\ansicpg1252\uc1\deff0{\fonttbl
{\f0\fnil\fcharset0\fprq2 Arial;}
{\f1\fswiss\fcharset0\fprq2 Arial;}
{\f2\froman\fcharset2\fprq2 Symbol;}}
{\colortbl;\red0\green0\blue0;\red255\green255\blue255;\red220\green20\blue60;}
{\stylesheet{\s0\itap0\nowidctlpar\f0\fs24 [Normal];}{\*\cs10\additive Default Paragraph Font;}}
{\*\generator TX_RTF32 16.0.534.502;}
\deftab1134\paperw12240\paperh15840\margl1440\margt1440\margr1440\margb1440\widowctrl\formshade\sectd
\headery720\footery720\pgwsxn12240\pghsxn15840\marglsxn1440\margtsxn1440\margrsxn1440\margbsxn1440\pard\itap0\nowidctlpar\plain\f1\fs17\cf3 Easements contained in the Plat and Dedication of 1000 DODGE BUILDING CONDO PROP REG*, filed August 03, 2015, as Document No. 11111111. Note: \plain\f1\fs17\ul\cf3{\txfielddef{\*\txfieldstart\txfieldtype1\txfieldflags24}{\*\txfielddatadef\txfielddatatype1\txfielddata 68007400740070003a002f002f007700770077002e006400720069007400690074006c0065002e0063006f006d002f00610064006400720065007300730064006f00630073002f00310036003700350033002f0050006c00610074002d003900380045002e007000640066000000}{\*\txfieldtext View Doc{\*\txfieldend}}{\field{\*\fldinst{ HYPERLINK "http://www.drititle.com/addressdocs/16753/Plat-98E.pdf" }}{\fldrslt{View Doc}}}}}
Is there any other tips you can provide?
BobRichards
Posts: 1150
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: Commitment Exceptions with Hyperlink

Post by BobRichards »

Glad you asked for additional information since after working with it for a couple of hours, I see that you cannot use it to add a hyperlink to an Exception. Upon further thought, since you are creating new text, you would have to also emulate our color and font scheme or your users would be confused with the different styles.

If anyone else has a solution, please post it to this thread.

Sorry.
Bob Richards, Senior Software Developer, SoftPro
tmeisinger
Posts: 74
Joined: Fri Apr 24, 2015 10:33 am

Re: Commitment Exceptions with Hyperlink

Post by tmeisinger »

Well, maybe not perfect, but here is the work around I came up with for Hyperlinking in an API created Exception. I loop through the Exceptions and grab the TEXT for the Exception and the LINK for the Exception. I place the Link at the end of the exception by using 'Note: View Document' and placing the Hyperlink on View Document. This is abbreviated VB.NET code of course...

Code: Select all

Dim rtf As New StringBuilder()
rtf.Append("{\rtf1\ansi\ansicpg1252\uc1\deff0{\fonttbl" & vbLf)
rtf.Append("{\f0\fnil\fcharset0\fprq2 Arial;}" & vbLf)
rtf.Append("{\f1\fswiss\fcharset0\fprq2 Arial;}" & vbLf)
rtf.Append("{\f2\froman\fcharset2\fprq2 Symbol;}}" & vbLf)
rtf.Append("{\colortbl;\red0\green0\blue0;\red255\green255\blue255;\red220\green20\blue60;}" & vbLf)
rtf.Append("{\stylesheet{\s0\itap0\nowidctlpar\f0\fs24 [Normal];}{\*\cs10\additive Default Paragraph Font;}}" & vbLf)
rtf.Append("{\*\generator TX_RTF32 16.0.534.502;}" & vbLf)
rtf.Append("\deftab1134\paperw12240\paperh15840\margl1440\margt1440\margr1440\margb1440\widowctrl\formshade\sectd" & vbLf)
rtf.Append("\headery720\footery720\pgwsxn12240\pghsxn15840\marglsxn1440\margtsxn1440\margrsxn1440\margbsxn1440\pard\itap0\nowidctlpar\plain\f1\fs17\cf3 ")
rtf.Append(TEXT + "  Note: ")
rtf.Append("\plain\f1\fs17\ul\cf3{\txfielddef{\*\txfieldstart\txfieldtype1\txfieldflags24}{\*\txfielddatadef\txfielddatatype1\txfielddata ")
rtf.Append(StringToHex(LINK))
rtf.Append("}{\*\txfieldtext" & vbLf)
rtf.Append("View Document{\*\txfieldend}}{\field{\*\fldinst{ HYPERLINK """)
rtf.Append(LINK)
rtf.Append(""" }}{\fldrslt{View Document}}}}}")

ExceptionObject.Text = rtf.ToString()
I created a little Function to convert the LINK to Hex as it looks like that is what you had done...

Code: Select all

Function StringToHex(ByVal text As String) As String
        StringToHex = ""
        For i As Integer = 0 To text.Length - 1
            StringToHex += Asc(text.Substring(i, 1)).ToString("x") & "00"
        Next
        StringToHex += "0000"
End Function
Once again, not glamorous, but it seems to work...
BobRichards
Posts: 1150
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: Commitment Exceptions with Hyperlink

Post by BobRichards »

I'm glad you found a solution that works for you.
Bob Richards, Senior Software Developer, SoftPro
jberney
Posts: 3
Joined: Thu Aug 19, 2021 12:03 pm

Re: Commitment Exceptions with Hyperlink

Post by jberney »

Hi There - This solution works for me. However, when inserting a link it seems like it doesn't insert the link correctly.

StringBuilder rtf = new StringBuilder();
rtf.Append(txtExceptionDescription);
rtf.Append(entry.Key + " Note: ");
rtf.Append(@"\plain\f1\fs17\ul\cf3{\txfielddef{\*\txfieldstart\txfieldtype1\txfieldflags24}{\*\txfielddatadef\txfielddatatype1\txfielddata");
rtf.Append(StringToHex("http://www.africau.edu/images/default/sample.pdf", System.Text.Encoding.Unicode));
rtf.Append(@"}{\*\txfieldtext" + Environment.NewLine);
rtf.Append(@"View Document{\*\txfieldend}}{\field{\*\fldinst{ HYPERLINK """);
rtf.Append(@""" }}{\fldrslt{View Document}}}}}");

ex.SetProperty("Text", rtf.ToString());
isSync= AddDocCodeToLookUpTbl(entry.Key);

if (!isSync)
syncTemplatesResponse.Message = "Document didnt save";

syncTemplatesResponse.Success = isSync;
os.ApplyChanges(order); // Save Order


So in Softpro I see this url in the exception. http://www.africau.edu/images/default/sample.pd

Does anyone know why? Am I doing something wrong?

Thank you in advance,
Jeff
jberney
Posts: 3
Joined: Thu Aug 19, 2021 12:03 pm

Re: Commitment Exceptions with Hyperlink

Post by jberney »

Attached a screenshot below
Attachments
Screenshot 2021-11-19 154652.jpg
Screenshot 2021-11-19 154652.jpg (53.91 KiB) Viewed 123 times
Post Reply