6 Replies Latest reply on Dec 11, 2009 10:05 AM by fraser

    Add web link to the content of a notification instance

    fraser

      Am trying to add a web link to the content of a notification. The web link will be dependent on the PI tag that the notification is triggered by. Therefore I am looking at writing some code that loops through each notification instance, looks at the attribute triggering the notification, references the PI tag of that attribute and then adds a web link (PI tag used in url) to the content of the notification.

       

      I can add a constant value to the content of the url using:

      Dim myContent As AFNotificationContent = myNotification.Contents.Add("Test")

      Any ideas on adding a url to the content will be much appreciated.

       

      Thanks

        • Re: Add web link to the content of a notification instance
          dmoler

          Hi fraser,

           

          Can you answer a couple questions about what you are trying to do:  Do you just want to add content for one of the standard delivery channels to use or is this for a custom delivery channel?  Will the URLs include all the tags that conditions are built on or just one each (it is not possible to identify the triggering tag)?

            • Re: Add web link to the content of a notification instance
              fraser

              Hi David,

               

              We want to add a link in the content to the adhoc trend web control with the single PI tag triggering the notification appended to the URL.
              We have hundreds of notifications – and we would like to programmatically set the link by enumerating through all the notifications, getting the PI tag associated with that notification and attaching it to the end of the adhoc web part URL.  We then want to assign this to the notification content.
              Eg:
              http://bkkhqntsp04:4242/RtWebPartResources/adhoctrendUrl.aspx?StartTime=%2A%2D7d&EndTime=%2A&Data=\\ & PI Tag

               

              The code we have tried so far is:

              Dim Content As AFNotificationContent = myNotificationResult.Contents.Add("TestURL6")
              Content.ContentType = AFNotificationContentType.DynamicLink

              Dim tmpVal As New AFValue
              tmpVal.Value = “http://bkkhqntsp04:4242/RtWebPartResources/adhoctrendUrl.aspx?StartTime=%2A%2D7d&EndTime=%2A&Data=\\ & PI Tag "
              Content.DisplayName = "TestURL6"

              Content.Attribute.SetValue(tmpVal)

               

              By manually adding a dynamic link to the notification content we have determined that the url is stored in the "value" column of the dbo.AFNotificationAttributeValue SQL table (as a varbinary data type). However when we define the AFNotificationContentType as DynamicLink, setting the value adds an entry to the "valuestring" column of the same table. We need a method that serializes the Dynamic link and stores it in the "value" column.

               

              Thanks

                • Re: Add web link to the content of a notification instance
                  dmoler

                  How does what you are trying to do differ from an Instant RtWebPart Trend?

                    • Re: Add web link to the content of a notification instance
                      cescamilla

                      If I read correctly, he is referring to the column that the notification stores the value on to. Is there a way to change that David?

                        • Re: Add web link to the content of a notification instance
                          dmoler

                          We can only support and test the products that we currently ship and have shipped in the past.  If this is a question of automating something that is possible but laborious through our UI, we can help.  That is what I am trying to get at - sorry if I was unclear on that point.  Doing things through a back door may work in the short term, it might break in a future version - it might even break in the current version if something unanticipated happens.  That will be a bad experience for the users and we all want to avoid that.

                           

                          I think the most effective approach will be to see if either 1) an Instant RtWebPart is what is desired or 2) the desired link can be built using the content > add > web link > other.  I understand that the tag values can't be entered this way, but if they can be hard-coded in the UI then they can be created programmatically.

                            • Re: Add web link to the content of a notification instance
                              fraser

                              Thanks guys, we managed to get it to work. By stepping through the vb debugger and by decoding the varbinary data in the "value" column of the dbo.AFNotificationAttributeValue to a string we were able to determine that the SetValue method was looking for a System.Collections.Generic.List.

                              Content.ContentType = AFNotificationContentType.DynamicLink
                              Content.DisplayName = myAttribDesc & " Trend Page"

                              Dim URLString As String = "http://bkkhqntsp04:4242/RtWebPartResources/adhoctrendUrl.aspx?StartTime=%2A%2D7d&EndTime=%2A&Data=" _
                                      & PI_Tag

                              Dim URLlist As New List(Of String)
                              URLlist.Add(URLString)
                              URLlist.Add(URLString)
                              URLlist.Add(URLString)
                              URLlist.Add(myAttribDesc & " Trend Page")
                              Content.Attribute.SetValue(URLlist, Nothing)

                              Yes the reason for developing this code was to automate, what would be the laborious task of adding a custom weblink to the content of every notification.