ModifyUserPropertyByAccountName

Aug 9, 2010 at 4:40 PM
Hi, When I try to update u user profile property with ModifyUserPropertyByAccountName, I get an error indicating "Object doesn't support this property or method" I use it this way: function updateUserProfileSetting(userId, propName, propValue) { var newData = new Array(); newData[0] = new Object(); newData[0].Name = propName; newData[0].Values = new Array(); newData[0].Values[0] = new Object(); newData[0].Values[0].Value = propValue $().SPServices.ModifyUserPropertyByAccountName({ accountName: userId, newData: newData }); } Is there an example using ModifyUserPropertyByAccountName somewhere? kind regards, karel
Coordinator
Aug 10, 2010 at 3:31 AM
Edited Aug 10, 2010 at 3:31 AM
karel:
It's pretty hard to be sure about what you're doing given the formatting of what you've posted. However, I think you're missing a semi-colon after this line:
newData[0].Values[0].Value = propValue
Also, your call to ModifyUserPropertyByAccountName isn't structured correctly. Check the General Syntax section here:
M.
Aug 10, 2010 at 8:14 PM
Hy Marc,

Thanks!
I restructured the code and now it works - almost:  if I pas an unknown user, I get a soap error in returm.
When I pass a known user, I get a soap response, but with an empty node.
Do you have any idea?

kind regards,

Karel

On Tue, Aug 10, 2010 at 5:31 AM, sympmarc <notifications@codeplex.com> wrote:

From: sympmarc

karel:
It's pretty hard to be sure about what you're doing given the formatting of what you've posted. However, I think you're missing a semi-colon after this line:
newData[0].Values[0].Value = propValue
Also, your call to ModifyUserPropertyByAccountName isn't structured correctly. Check the General Syntax section here:
M.

Read the full discussion online.

To add a post to this discussion, reply to this email (SPServices@discussions.codeplex.com)

To start a new discussion for this project, email SPServices@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com




--
Karel Vandenhove
Somak s.a.
IT Consultant
+32473962759
Coordinator
Aug 11, 2010 at 3:24 AM

Karel:

Hard to say without seeing your code. You must be passing something invalid in or intepreting something incorrectly on the way out.

M.

Aug 11, 2010 at 8:04 AM
Hi Marc,
 
Thanks for your quick response!
 
This is the function used for changing the setting:
 
function updateUserProfileSetting(userId, propName, propValue) {

     var newData = new Array();
     newData[0] = new Object();
     newData[0].Name = propName;
     newData[0].Values = new Array();
     newData[0].Values[0] = new Object();
     newData[0].Values[0].Value = propValue;


     $().SPServices({
         operation: "ModifyUserPropertyByAccountName",
         // Force sync so that we have the right values for the child column onchange trigger
         async: false,
         webURL: "http://dell-dev-dev25/my",
         accountName: userId,
         newData: newData,
         completefunc: function (xData, Status) {
             var test = $(xData.responseXML);
         }
     });
 }

It is called like this (sortOrder is a string value): 
	 var userObject = web.get_currentUser();
 var userId = userObject.get_loginName();
 var propName = "DashboardSettings";
 updateUserProfileSetting(userId, propName, sortOrder);
The userId is correct: if I hardcode an unknown userId I get an exception.
With a known userId the value for xData.responseXML.xml is
 
The ModifyUserPropertyByAccountNameResponse node is empty.
 
Kind regards,
 
Karel
 
On Wed, Aug 11, 2010 at 4:24 AM, sympmarc <notifications@codeplex.com> wrote:

From: sympmarc

Karel:

Hard to say without seeing your code. You must be passing something invalid in or intepreting something incorrectly on the way out.

M.

Read the full discussion online.

To add a post to this discussion, reply to this email (SPServices@discussions.codeplex.com)

To start a new discussion for this project, email SPServices@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com




--
Karel Vandenhove
Somak s.a.
IT Consultant
+32473962759
Coordinator
Aug 11, 2010 at 11:34 AM

Ah. I see the problem. You're trying to pass objects to the Web Service. You can only pass text in XML. Youre seeing nothing back in the response because you're not passing anything in.

A little quick Binging got me this snippet example of what the XML might need to look like:

<PropertyData>
          <IsPrivacyChanged>false</IsPrivacyChanged>
          <IsValueChanged>true</IsValueChanged>
          <Name>UserProfilePropertyName</Name>
          <Privacy></Privacy>
          <Values>
            <ValueData xsi:nil="true" ></my:Group/my:Field></ValueData>
            <ValueData xsi:nil="true" />
          </Values>
</PropertyData>

It's probably not totally right, but you should get the idea. XML is text based, not object based.

If you come up with a working example, please post it back so that I can make it available in the docs!

M.

Aug 11, 2010 at 12:38 PM
Great,  thanks!!

On Wed, Aug 11, 2010 at 12:34 PM, sympmarc <notifications@codeplex.com> wrote:

From: sympmarc

Ah. I see the problem. You're trying to pass objects to the Web Service. You can only pass text in XML. Youre seeing nothing back in the response because you're not passing anything in.

A little quick Binging got me this snippet example of what the XML might need to look like:

<PropertyData>
          <IsPrivacyChanged>false</IsPrivacyChanged>
          <IsValueChanged>true</IsValueChanged>
          <Name>UserProfilePropertyName</Name>
          <Privacy></Privacy>
          <Values>
            <ValueData xsi:nil="true" ></my:Group/my:Field></ValueData>
            <ValueData xsi:nil="true" />
          </Values>
</PropertyData>

It's probably not totally right, but you should get the idea. XML is text based, not object based.

If you come up with a working example, please post it back so that I can make it available in the docs!

M.

Read the full discussion online.

To add a post to this discussion, reply to this email (SPServices@discussions.codeplex.com)

To start a new discussion for this project, email SPServices@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com




--
Karel Vandenhove
Somak s.a.
IT Consultant
+32473962759
Aug 12, 2010 at 2:26 PM
Marc,
 
Thank you for helping me on the right track.
This works: in the ValueData the value has to be embedded in a node with the right value type.  (I created a small ws client, fiddled et voilà)
 
kind regards,
 
Karel
 var propertyData = 
 "<PropertyData>" +
 "     <IsPrivacyChanged>false</IsPrivacyChanged>" +
 "     <IsValueChanged>true</IsValueChanged>" +
 "     <Name>" + propName + "</Name>" +
 "     <Privacy>NotSet</Privacy>" +
 "     <Values><ValueData><Value xsi:type=\"xsd:string\">" + propValue + "</Value></ValueData></Values>" +
 "</PropertyData>";

 $().SPServices({
 operation: "ModifyUserPropertyByAccountName",
 // Force sync so that we have the right values for the child column onchange trigger
 async: false,
 webURL: "http://dell-dev-dev25/my",
 accountName: userId,
 newData: propertyData,
 completefunc: function (xData, Status) {
 var result = $(xData.responseXML);
 }
 });


On Wed, Aug 11, 2010 at 12:34 PM, sympmarc <notifications@codeplex.com> wrote:

From: sympmarc

Ah. I see the problem. You're trying to pass objects to the Web Service. You can only pass text in XML. Youre seeing nothing back in the response because you're not passing anything in.

A little quick Binging got me this snippet example of what the XML might need to look like:

<PropertyData>
          <IsPrivacyChanged>false</IsPrivacyChanged>
          <IsValueChanged>true</IsValueChanged>
          <Name>UserProfilePropertyName</Name>
          <Privacy></Privacy>
          <Values>
            <ValueData xsi:nil="true" ></my:Group/my:Field></ValueData>
            <ValueData xsi:nil="true" />
          </Values>
</PropertyData>

It's probably not totally right, but you should get the idea. XML is text based, not object based.

If you come up with a working example, please post it back so that I can make it available in the docs!

M.

Read the full discussion online.

To add a post to this discussion, reply to this email (SPServices@discussions.codeplex.com)

To start a new discussion for this project, email SPServices@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com




--
Karel Vandenhove
Somak s.a.
IT Consultant
+32473962759
Coordinator
Aug 12, 2010 at 8:22 PM

Karel:

Thanks for sharing your example. I've added it to the documentation for ModifyUserPropertyByAccountName.

M.


Aug 12, 2010 at 8:43 PM
My pleasure, and thank you for a wonderful job!

On Thu, Aug 12, 2010 at 10:23 PM, sympmarc <notifications@codeplex.com> wrote:

From: sympmarc

Karel:

Thanks for sharing your example. I've added it to the documentation for ModifyUserPropertyByAccountName.

M.



Read the full discussion online.

To add a post to this discussion, reply to this email (SPServices@discussions.codeplex.com)

To start a new discussion for this project, email SPServices@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com




--
Karel Vandenhove
Somak s.a.
IT Consultant
+32473962759