UpdateListItem to create new discussion - issues

Jan 7, 2011 at 3:40 PM

When using UpdateListItem to create a new discussion topic, some anomalies occur (which is likely just inherent to disc boards, as they are T-R-O-U-B-L-E!!)

Even though I am providing the value for internal field name "Title", this value only appears in the DisplayName field "Subject".  The value of Title becomes some weird form of the ID - something like 8_.000000- I am fine with that, it's just that it then appears in the breadcrumb as well

Also, the first post normally looks like:

SUBJECT TITLE HERE

Body of the first post

Instead, only the body is displayed.

Thanks for any guidance you can provide, even if it is just that it should only be used for lists!!

Sample of pertinent part of code:

    $().SPServices({
        operation: "UpdateListItems",
        async: false,
        listName: "Team Discussion",
        updates: "<Batch OnError='Continue' PreCalc='TRUE'>" +
                    "<Method ID='1' Cmd='New'>" +
                        "<Field Name='Title'>" + Subject + "</Field>" +
                        "<Field Name='Body'>" + Body + "</Field>" +
                    "</Method>" +
                "</Batch>",
        completefunc: function (xData, Status) {
            //get the ID for the newly created Issue
            var newID = $(xData.responseXML).find("[nodeName=z:row]").attr("ows_ID");
            alert("The discussion has been created.  You will now be sent to that page to complete the thread.");
Coordinator
Jan 7, 2011 at 8:11 PM

will266:

I just tested this in my enviroment and it created a Discussion item that looked the way I would expect:

<script language="javascript" type="text/javascript">
	$(document).ready(function() {
		alert("Hi");
		var Subject = "blah";
		var Body = "blah blah";
		$().SPServices({
	        operation: "UpdateListItems",
	        async: false,
	        listName: "Team Discussion",
	        updates: "<Batch OnError='Continue' PreCalc='TRUE'>" +
	                    "<Method ID='1' Cmd='New'>" +
	                        "<Field Name='Title'>" + Subject + "</Field>" +
	                        "<Field Name='Body'>" + Body + "</Field>" +
	                    "</Method>" +
	                "</Batch>",
	        completefunc: function (xData, Status) {
	            //get the ID for the newly created Issue
	            var newID = $(xData.responseXML).find("[nodeName=z:row]").attr("ows_ID");
	            alert("The discussion has been created.  You will now be sent to that page to complete the thread.");
	        }
	 	});
	 });
</script>
I'm not sure what happened in your environment, but give it another try.
M.
Jan 10, 2011 at 4:13 PM

Weird - I took your code, dropped in my references to jQuery and SPServices.  On page load, I got the alert, then the message box. 

When I went to my Team Discussion, the entry was there - looking normal.  When I click into it, I see the breadcrumb references 1_.000, and the body of the post is "blah blah" where I would expect, if I were to create a normal manual post, for the post to have been:

blah

blah blah

When I look at the list view and add the column "Title", it show 1_.000 instead of blah.

Can you confirm that when you go into the actual post, all is well (i.e. post body contains subject and body, and breadcrumb says blah)

I am on: MOSS2007, WSS3, and IE 8.  Here is the code I used...

<SCRIPT type=text/javascript src="http://idnetmonitor/sites/rc/mastercode/jquery.current.min.js"></SCRIPT>

<SCRIPT type=text/javascript src="http://idnetmonitor/sites/rc/mastercode/jquery.SPServices.current.min.js"></SCRIPT>

<script language="javascript" type="text/javascript">
	$(document).ready(function() {
		alert("Hi");
		var Subject = "blah";
		var Body = "blah blah";
		$().SPServices({
	        operation: "UpdateListItems",
	        async: false,
	        listName: "Team Discussion",
	        updates: "<Batch OnError='Continue' PreCalc='TRUE'>" +
	                    "<Method ID='1' Cmd='New'>" +
	                        "<Field Name='Title'>" + Subject + "</Field>" +
	                        "<Field Name='Body'>" + Body + "</Field>" +
	                    "</Method>" +
	                "</Batch>",
	        completefunc: function (xData, Status) {
	            //get the ID for the newly created Issue
	            var newID = $(xData.responseXML).find("[nodeName=z:row]").attr("ows_ID");
	            alert("The discussion has been created.  You will now be sent to that page to complete the thread.");
	        }
	 	});
	 });
</script>

Coordinator
Jan 12, 2011 at 11:58 AM

Ah, yes I see what you mean with the breadcrumb looking like 5_.000. missed that when I set it up.

I'm not sure exactly what the solution is, but I think I see where it goes south on us. The two column below are set to the ID rather than the text of the Title, as they are if you create an item through the UI. See full examples below. Post 1 was added through the UI.)

14 ows_FileLeafRef 5;#5_.000
15 ows_FileRef 5;#Intranet/JQueryLib/Lists/Team Discussion/5_.000

M.


z:row  
0 ows_LinkDiscussionTitle blah
1 ows_Author 3;#Marc D Anderson
2 ows_ItemChildCount 5;#0
3 ows_DiscussionLastUpdated 2011-01-07 16:23:48
4 ows_MetaInfo 5;#
5 ows__ModerationStatus 0
6 ows__Level 1
7 ows_Title blah
8 ows_ID 5
9 ows_owshiddenversion 1
10 ows_UniqueId 5;#{D99F3548-9B31-4C2B-A28C-39FB4C526BE3}
11 ows_FSObjType 5;#1
12 ows_Created_x0020_Date 5;#2011-01-07 16:23:49
13 ows_Created 2011-01-07 16:23:48
14 ows_FileLeafRef 5;#5_.000
15 ows_FileRef 5;#JQueryLib/Lists/Team Discussion/5_.000
z:row  
0 ows_LinkDiscussionTitle blah
1 ows_Author 3;#Marc D Anderson
2 ows_ItemChildCount 4;#0
3 ows_DiscussionLastUpdated 2011-01-07 16:13:49
4 ows_MetaInfo 4;#
5 ows__ModerationStatus 0
6 ows__Level 1
7 ows_Title blah
8 ows_ID 4
9 ows_owshiddenversion 1
10 ows_UniqueId 4;#{EF07C0A3-8D51-4918-B23A-89CC7DA80082}
11 ows_FSObjType 4;#1
12 ows_Created_x0020_Date 4;#2011-01-07 16:13:50
13 ows_Created 2011-01-07 16:13:49
14 ows_FileLeafRef 4;#4_.000
15 ows_FileRef 4;#JQueryLib/Lists/Team Discussion/4_.000
z:row  
0 ows_LinkDiscussionTitle Here's the initial post
1 ows_Author 3;#Marc D Anderson
2 ows_ItemChildCount 1;#2
3 ows_DiscussionLastUpdated 2010-01-21 11:09:00
4 ows_MetaInfo 1;#
5 ows__ModerationStatus 0
6 ows__Level 1
7 ows_Title Here's the initial post
8 ows_ID 1
9 ows_owshiddenversion 1
10 ows_UniqueId 1;#{33A90EC4-725B-4D7B-83EA-66A2F3DB7124}
11 ows_FSObjType 1;#1
12 ows_Created_x0020_Date 1;#2009-08-06 09:10:09
13 ows_Created 2009-08-06 09:10:08
14 ows_FileLeafRef 1;#Here's the initial post
15 ows_FileRef 1;#JQueryLib/Lists/Team Discussion/Here's the initial post