Vikram404@hotmail.com
Guest
|
Posted:
Wed Jan 19, 2005 8:59 pm Post subject:
Creating Search Alerts Programmatically |
|
|
Hi,
I am trying to extend SPS2003, by adding a custom webservice in which I can
add an alert to a search query using the SPS Object Model. Here is the code
snippet which I am using:
---------------------------------
CODE
---------------------------------
AlertManager objAlertManager = null;
AlertType objAlertType = null;
Alert objAlert = null;
AlertCollection objAlertCollection = null;
PortalChannelSettings objPortalChannelSettings = null;
//Retrieve the current Portal Context.
objAlertManager = new AlertManager(PortalContext.Current);
//Retrieve the Alerts Collection.
objAlertCollection = objAlertManager.GetMyAlerts();
//Create an object of type SearchAlert
objAlertType = new SearchAlertType();
//Create a New Alert by specifying the AlertType as SearchAlert
objAlert = objAlertCollection.CreateAlert(objAlertType);
objAlert.Name = "My New Alert101";
objAlert.ConditionText = "Alert for Search";
objAlert.UrlRenderingPortalZone = PortalZone.Intranet;
objAlert.Query = strQuery;
objPortalChannelSettings = new PortalChannelSettings();
objAlert.DeliveryChannels.Add(objPortalChannelSettings);
//Commit the AlertData
objAlert.Commit();
---------------------------------
The strQuery contains a full text sql query which is:
strQuery = "SELECT
\"DAV:displayname\",\"urn:schemas.microsoft.com:fulltextqueryinfo:displaytitle\",\"urn:schemas.microsoft.com:fulltextqueryinfo:description\",\"DAV:contentclass\",\"DAV:href\"
FROM ( TABLE Portal_Content..SCOPE() UNION ALL TABLE
Non_Portal_Content..SCOPE() ) WHERE ( FREETEXT(*, 'office') ) ORDER BY
\"urn:schemas.microsoft.com:fulltextqueryinfo:rank\" DESC";
---------------------------------
The error I am getting is:
"The query string is poorly formed. \nParsing Errors: \nErr: 80040e14,
80040e14, selectErr:80040e14, 80040e14, '(', '*', NOT, CAS"
Please let me know what could be wrong ?
Does anyone have a code sample for doing this ?
Thanks and Regards,
Vikram |
|
Vikram404@hotmail.com
Guest
|
Posted:
Wed Jan 19, 2005 9:29 pm Post subject:
RE: Creating Search Alerts Programmatically |
|
|
Ok, I need to send just the WHERE part of the query and it works fine...
Anyone has any idea how I can apply SCOPE in that case ?? I mean in terms of
the
FROM part of the query like Portal_Content and Non_portal_Content ...
Thanks,
Vikram
"Vikram404@hotmail.com" wrote:
| Quote: | Hi,
I am trying to extend SPS2003, by adding a custom webservice in which I can
add an alert to a search query using the SPS Object Model. Here is the code
snippet which I am using:
---------------------------------
CODE
---------------------------------
AlertManager objAlertManager = null;
AlertType objAlertType = null;
Alert objAlert = null;
AlertCollection objAlertCollection = null;
PortalChannelSettings objPortalChannelSettings = null;
//Retrieve the current Portal Context.
objAlertManager = new AlertManager(PortalContext.Current);
//Retrieve the Alerts Collection.
objAlertCollection = objAlertManager.GetMyAlerts();
//Create an object of type SearchAlert
objAlertType = new SearchAlertType();
//Create a New Alert by specifying the AlertType as SearchAlert
objAlert = objAlertCollection.CreateAlert(objAlertType);
objAlert.Name = "My New Alert101";
objAlert.ConditionText = "Alert for Search";
objAlert.UrlRenderingPortalZone = PortalZone.Intranet;
objAlert.Query = strQuery;
objPortalChannelSettings = new PortalChannelSettings();
objAlert.DeliveryChannels.Add(objPortalChannelSettings);
//Commit the AlertData
objAlert.Commit();
---------------------------------
The strQuery contains a full text sql query which is:
strQuery = "SELECT
\"DAV:displayname\",\"urn:schemas.microsoft.com:fulltextqueryinfo:displaytitle\",\"urn:schemas.microsoft.com:fulltextqueryinfo:description\",\"DAV:contentclass\",\"DAV:href\"
FROM ( TABLE Portal_Content..SCOPE() UNION ALL TABLE
Non_Portal_Content..SCOPE() ) WHERE ( FREETEXT(*, 'office') ) ORDER BY
\"urn:schemas.microsoft.com:fulltextqueryinfo:rank\" DESC";
---------------------------------
The error I am getting is:
"The query string is poorly formed. \nParsing Errors: \nErr: 80040e14,
80040e14, selectErr:80040e14, 80040e14, '(', '*', NOT, CAS"
Please let me know what could be wrong ?
Does anyone have a code sample for doing this ?
Thanks and Regards,
Vikram
|
|
|