0

I am trying to set a URL Field to update the Description and every time i run this ClientSide (via Powershell) I get the following error

Exception calling "ExecuteQuery" with "0" argument(s): "Invalid URL: Microsoft.SharePoint.Client.FieldUrlValue

Basically what I'm trying to do is to set the URL to a Folder in a Document Library for a Specific User

The List will show

Users Name

Dept

Team

Document Library URL

Currently it shows it all correctly however its not that nice to see a huge URL in the Document Library URL field hence I want to Update it to show the Description which should show "User's Documents"

Easy done on Server Side and I have it Working on Server Side - However I would like to set this Client Side

So an example is

Ryan

IT

SharePoint

Http://SP.Ryan.Test/sites/IT/SharePoint/Ryan


$url = $item["Document_x0020_Url"].url
$ofldurl= new-object Microsoft.SharePoint.Client.FieldUrlValue
$ofldurl.URL = $url
$ofldurl.Description = $item["Title"]+"'s"+" "+"Documents"
$item["Document_x0020_Url"] = $ofldurl
$item.update()
$context.ExecuteQuery()         

I have double Checked and the URL is Set correctly in the Class (or at least it seems it to me) below is the output from the FieldURLValue Variable I had Created

Url

http://SP.Ryan.Test/sites/IT/SharePoint/Ryan              

Description 

Ryan's Documents                                        

TypeId

{fa8b44af-7b43-43f2-904a-bd319497011e}

Can Anyone see why this is not working at all or is this just me having a bad day?

2

I've analyzed the requests sent by your PowerShell snippet and an equivalent version sent by "native" managed client object modell by Fiddler. As far as I see, the difference is caused by the way PS handles (casts) objects in the background.

I found, that this version does what you need:

ofldurl= New-Object Microsoft.SharePoint.Client.FieldUrlValue
$url = $item["Document_x0020_Url"].Url
$ofldurl.Description = $item["Title"]+"'s"+" "+"Documents"
$ofldurl.Url = $url
$item["Document_x0020_Url"] = [Microsoft.SharePoint.Client.FieldUrlValue]$ofldurl
$item.Update()
$context.ExecuteQuery()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.