Is there a way to control who the last modified person is on a sharepoint list item - sharepoint-2013

For example: If Bob is a content owner and needs to open the item to view more detailed information for example, when Bob closes that item his name should not replace the name of the non-content owner who last modified that item.

Filter the view and checkout metadata. You can see who modified last.

Related

SharePoint lists, unique to user

I have a SharePoint list which has multiple users, is there a way that when each user opens the list they can only see the row relevant to them?
Edit the view, and add a filter:
Column: Created by
is equal to
[Me]
Then each person who looks at that view will see only the items they created. [Me] compares the column to the currently logged in username.

DropList field in WFFM is showing value in message body

we have identified an issue/functional requirement that we have a droplist of countries and same goes for title like in below image
but we need that in response email body of send email save action it's Arabic text should be used instead of English value of selected option. Is there a solution or fix ? or we have to go for any customization ?
I don't think there is a way out-of-the-box to use the text instead of value. What you can do is create a custom "Send Email Message", similar to Sitecore.Form.Submit.SendMail and override the FormatMail method.
Create a list of countries items somewhere in the Sitecore Content Tree, and add a field for the text/description of the country. Then in WFFM droplist field, Set Items by: Selecting Sitecore Items and Select Root Item to the folder of the list of countries you created earlier.
You should see the countries in the preview section. Click the drop arrow for the Value and Text fields and then either select Display name or the custom field in your country item that holds the translated values.
The value submitted in form will now be the translated value correct for the language, using the lookup items list.

Sitecore - Validate a drop list value change event

I have a sitecore item, "category", which has a drop link which populate "product type" template list.
Each category can have a "product type".
(Products being created under a category node will be using the template selected in the drop down. e.g. Shoes category will have a Shoes template, Slippers category will also have a shoes template, Bags category will have a bags template).
Problem:
These categories should be able to mark related categories. Therefore I need to show a treelist kind of a control which only allows options to select categories with same "product type".
Under "Shoes" category, I need to have "Slippers".
How can I do this?
After selecting "Slippers" as the related item to "Shoes", if the user tries to change the "product type" drop link value in "slippers", how can I warn the user that this product type has already linked to another category?
(Validation on saving the category item.)
Hope this is a common issue with Related items in Sitecore, yet I could not find a solution for this.
Your first problem, "marking related categories" is not clear to me what you want to achieve with it.
But if I understand you correctly, you want to select a product-type-template in the Category-item to let the editor create products of the chosen producttype below the Category-item.
You can resolve this by using the item:saved event on the Category-item:
- first check if you are saving an item of type Category but checking the template.
- If it is a Category-Item, read the value of the product-type droplink and on the fly add this template to the insert-option of the Category item.
Your second problem with the check on related items can merely handled the same way by using the item:saving event. Not the item:saved event because you want to do the check before the item is saved so you can cancel the saving and display a messagebox through the Sitecore.Web.UI.Sheer.SheerResponse.Alert() method.
In the item:saving event you need to check if the current item has 1 or more referrers (items that link to this item) through the LinkDatabase method Globals.LinkDatabase.GetReferrers().
Using validation on this instead of the item:saving event is not usefull because the validation event only throws a warning and saves the item anyway.
Another good link with example code is this blog of John West.

How can I check that an item already exists in a SharePoint list?

I wish to create an event receiver that, when adding an item through an InfoPath form from one list to another, it will not create a new item if the item already exists, it will just update the 'quantity' of that item.
Eg.
Stock Items List > Add 2 Milk to Cart > Milk is already in Cart > Updates Milk to Quantity of 3.
You should have a unique key to identify your item. Ideally this would be a number or something like that, so you can identify the item in the second list. In your example with the milk, you don't have an ID. So you could add one or you could just compare the item with the text (I suppose "Milk" will be in the title field)
When the item is being added in the list you can then in the "ItemAdding" check with an SPQuery if the item already exists in the list (enough examples to find online). If query returns 0 items, you can just let SharePoint do it's work as it normally should. If an item is found you should then update the quantity of the found item.
2 remarks you should take into account:
To avoid that the item is being added when it already is in the list you can use following code.
properties.Cancel = true;
properties.Status = SPEventReceiverStatus.CancelNoError
The cancel makes sure that the item is not being added. Normally this throws an error but by setting the status no error is thown.
The second thing you should take into account is if you want to let the item update fire on updating the quantity. Because this can cause strange behavior. I would recommend disabling event firing before updating the quantity and then enable it again.

Sitecore 6 - how to store html-formatted text and reference in codebehind

I would like to be able to store reusable html-formatted text in Sitecore and reference in codebehind for inclusion in a custom user control. What is the best practice for doing this? If a user selects option A, for example, I would reference standard text A in my control. Any examples for how to accomplish this are appreciated. Thanks.
You have a couple options:
Store the text in the Standard Values of the same template that defines your option list. That makes it available on the same item, but standard for all items. Use security to lock down the field if you are worried about it being edited. This could also be accomplished with the new "cloning" feature in 6.4, I believe.
Create a structure outside of your Home element for storing this data. Based on the option selected, find an item in your content tree which corresponds to the selected item, and read the text off of it. You would need to find this item either relative to /sitecore/Content, or relative to your website root if multi-site support is a requirement.
No.2 in pseudo-code:
//get the item where we have the text values
Item textBase = Sitecore.Context.Database.SelectSingleItem(textBasePath);
//find the child w/ the same name as the selected option
Item textItem = textBase.Axes.GetChild(selectedOptionValue);
string value = textItem["text"];
I think I would do something like techphoria414's 2. option:
ie you have your normal "page" templates as per usual, but then you have some fields (multilist, treelist fields), where you put the source pointing to your other items contain the different texts.
then you basically just have to get the items from the current item (with some very quick'n'dirty code/pseudocode):
var CurrentItem = Sitecore.Context.Item;
Sitecore.Data.Fields.MultilistField mlf1 = CurrentItem.Fields["myExternalTexts"];
if(mlf1 != null)
{
foreach (Item itm in mlf1.GetItems())
{
lit += Sitecore.Web.UI.WebControls.FieldRenderer.Render(itm, "richtext");
}
}
You ofc shouldn't just add them to a literal and you should you Sitecore built in Field renderes if using Sitecore 6 or above and it's a Rich text field.
I hope that helps.