Can I update the Modified By value in Sharepoint with another value? - sharepoint

In a Sharepoint document library, I've some documents with version history. In C#, can I get the version history of a document and update the user?
The version history of the document is something line this:
Data Modified By
---- -----------
doc1 changed User X
some text User X
Using C#, can I update the Modified By user value with another user?

I'm guessing right now, but I think it should be possible to modify this value with object model without any problem. Just set it in your code with value you like ([UserId];#[SERVER\LoginName]) and instead of using Update method, use `SystemUpdate'. I'm quite sure that it works for Lists, didn't test it on Document Libraries.

Assuming you have the list item in oListItem, you need to set the Editor of the ListItem field by using FieldUserValue object:
FieldUserValue fldUser = new FieldUserValue();
fldUser.LookupId = User.Id;
clientContext.Load(fldUser);
clientContext.ExecuteQuery();//or use another way to get your user
oListItem["Editor"] = fldUser;

Related

Request data format for category field update

I am using the podio-js package in a project designed to handle our invoicing. I am currently facing a problem in my attempts to update an item's category type field.
Here is the code I am currently running with:
const url = `/item/${item_id}/value/${field_id}`;
// newOptionId is the id of the option I want to switch to
const requestData = JSON.stringify({[field_id]: newOptionId});
const responseData = await this.podio.request('PUT', url, requestData);
I tried several other formats as described here: https://developers.podio.com/doc/items/add-new-item-22362, but every time I get the same result, it unselects the current selected option and leaves my category type field with no selected option.
Please provide me with the correct requestData format as I think the problem is coming from there.
Thanks.
The request format {value: your_id} is not supported anymore, it worked for me using this.podio.request('PUT', url, [myId]) to update a category field.
#Podio team: it would be cool to update and complete your documentation.
There are 4 slightly different ways of setting value to a field.
1. One when creating new item Podio: create item
2. Another one when updating whole item Podio: update item. This includes for example reverting to specific revision or setting each and every field including meta-fields like files, reminders, recurrences, etc.
3. Yet another one is updating item value Podio: update item value, which is updating whole item but only fields. So, it only accepts content that is inside fields parameter for methods #1 and #2 above.
4. And one more is for updating item field values Podio: update item field values. This one expects values for single field and only content of fields['field_id'] from methods #1 and #2 should be passed here.
Each way requires different format for value and uses different url.
I've updated documentation to include 2 cURLs examples for last 2 methods to make it clear, but will be happy to include additional explanations if you provide them.

Pre defining and pre populating a field in Couchdb

I am trying to pre define and possibly pre populate a field in CouchDB every time a new document is created by the user. That is until a user enters a different value the initial value that I created will stay.
According to this article it is not possible to do so: (CouchDB: Pre-filled fields when adding new documents?)
I was just wondering if there was an update to this. Or is there an easier way to do this?

sharepoint lookup field how to programmatically filter to lookup only in current document library

I want the lookup field to be filtered to only display titles from the current document library (meaning the document library that the user is currently in). I cannot specify the document library b/c I don't want to have to define a new lookup column for each new document library...instead I'm hoping to do this as a custom content type that can be used in any document library.
It would ideally be deployed as a feature.
Look into http://msdn.microsoft.com/en-us/library/ms446361.aspx">SharePoint Custom Fields.
http://msdn.microsoft.com/en-us/library/ms446361.aspx
This kind of feature does not exist on SharePoint OTB.
Take look at this thread: http://social.technet.microsoft.com/forums/en-us/sharepointadmin/thread/722EE26B-EC33-4618-8041-FAA92E149DE8. It provides some solutions though.

How to create a lookup column that targets a Doc Lib and uses the 'Name' of the document?

How do you create a lookup column to a Document Library that uses the 'Name' of the document as the lookup value?
I found a blog post that recommends adding another custom field like "FileName" and then using a item reciever to populate the custom field with the value from the Name field but that seems cheesy.
Link to the blog in case people are interested:
http://blogs.msdn.com/pranab/archive/2008/01/08/sharepoint-2007-moss-wss-issue-with-lookup-column-to-doc-lib-name-field.aspx
I've got a bunch of custom document content types that I dont want to clutter with a work around that should really work anyway.
I created a one step workflow to set the title from the name, fired on modify and created. Seems to work and took seconds to create.
One way you can do this (although not the easiest way) is by creating a custom field type that extends the SPFieldLookup class. SharePoint's field editor for Lookup fields purposefully hides any columns types that aren't supported by Lookup fields, but you can create a field editor for your custom field type that shows them.
However, I have created a Lookup column that points to a Name column in a Document Library before, and it probably doesn't work like you'd expect. While the value stored in the lookup column is valid, it doesn't show up right in List view or on the View Properties form.
The solution you posted may actually be the best way to handle this. Lookup fields require some kludges if you want to handle more complex scenarios, but that's because they're not meant to provide the same functionality as a foreign key relationship in a database.
Coding in any form always scares me. So Here's what I did: I simply renamed the Stupid "Title" Field to something else, say "Keywords", since you cant do anything with that field: cant even make it mandatory.
Then I created another Single line field called "Title" and used this field for the Lookups
Well there is a simple solution to that and in might work in some case.
In the nutshell if you make the Title field Mandatory, this will force the user to enter a title. In that manner we can use title field as a lookup field.
Now How to do that?
One you are done create a document library go to the library setting. Select Advance Setting and Select Yes for the option "Allow management of content types?".
Then go back to the Library setting and Under content types select the "Document" Content type. THen Select Title Column and then Select "Required (Must contain information)" and say OK.
Now try uploading a document to this document library. You will see Title field in the form.
Hope this helps
Cheers
Vaqar
You have to add the field as XML with the ShowField as 'FileLeafRef'
var XmlFieldDefinition = "<Field DisplayName='myLookupColumn' Type='LookupMulti' StaticName='myLookupColumn' Name='myLookupColumn' Required='FALSE' List='THE LOOKUP ID HERE' WebId='THE WEB ID HERE' UnlimitedLengthInDocumentLibrary='TRUE' Mult='TRUE' Sortable='FALSE' ShowField='FileLeafRef' />"
Field fld = fieldCollection.AddFieldAsXml(XmlFieldDefinition, true, AddFieldOptions.DefaultValue);
ClientContext.Load(fld);
ClientContext.ExecuteQuery();

non-database field on ClearQuest form

Is there a way to use form fields that does not correspond to database field for temporary processings?
I.e. I want to add:
temp fields item1, item2
database field sum
button with record hook that sets sum = item1 + item2
As far as I know it's simply not possible with ClearQuest.
I've tried to do something similar and was told by our IBM consultant that the only way is to create a DB field for all variables.
You can't attach data to form fields really - those are representations of the underlying data, not something scripts interact with directly.
Adding temporary data to the underlying record (entity) itself sounds unlikely as well. Perhaps it's possible to abuse the perl API and dynamically attach data to entity objects but I personally wouldn't try it, you're liable to lose your data at the whim of CQ then ;-)
That does not however mean it's impossible to have temporary data.
The best way seems to me to be using the session object, which is explicitly intended for that purpose.
From the helpfile:
IBM Rational ClearQuest supports the
use of sessionwide variables for
storing information. After you create
sessionwide variables, you can access
them through the current Session
object using functions or subroutines,
including hooks, that have access to
the Session object. When the current
session ends, all of the variables
associated with that Session object
are deleted. The session ends when the
user logs out or the final reference
to the Session object ceases to exist.
There's some helpful documentation on this subject in file:///C:/Program%20Files/Rational/ClearQuest/doc/help/cq_api/c_session_vars.htm (Presuming a default installation on a windows machine, of course.)
Translating the code example in there into what you seem to be wanting, first you store the data you have calculated inside the session object:
$session->SetNameValue("item1", $value1);
$session->SetNameValue("item2", $value2);
Then in your calculation hook you retrieve the stored values and set the value of that totals field like this:
my $item1 = GetNameValue("item1");
my $item2 = GetNameValue("item2");
my $sum = $item1 + $item2;
$entity->SetFieldValue("some_totals_record", $sum);
Adjust to taste of course ;-)
ClearQuest schema designers often include 'temporary' fields in their record types. They do this so they perform operations on hooks to generate another value.
For example, for the Notes fields, there is a 'temporary' Notes_entry field that the user types the most recent note into, and when the record is saved, the value is added to the Notes_Log field. The next time the record is edited the Notes_entry field is cleared so the user can type a new Notes_entry.

Resources