Affichage des articles dont le libellé est SharePoint. Afficher tous les articles
Affichage des articles dont le libellé est SharePoint. Afficher tous les articles

lundi 11 avril 2022

Field data types fingerprints for "validateUpdateListItem"

Field data types fingerprints for "validateUpdateListItem"

With "validateUpdateListItem" all major field data types update is supported, yet it can be difficult sometimes to find the correct format. So as a bonus section: 


.validateUpdateListItem([
  // Text field (single line and note)
  { FieldName: 'TextField', FieldValue: '123' },
  // Number field
  { FieldName: 'NumberField', FieldValue: '123'  },
  // Yes/No field
  { FieldName: 'YesNoField', FieldValue: '1' /* Yes, No, 1, 2 */ },
  // Person or group, single and multiple
  { FieldName: 'PersonField', FieldValue: JSON.stringify([{ Key: LoginName }]) },
  // Dates should be in in the following formats
  { FieldName: 'DateTimeField', FieldValue: '6/23/2018 10:15 PM' },
  { FieldName: 'DateField', FieldValue: '6/23/2018' },
  // Choice field (single and multi-valued)
  { FieldName: 'ChoiceField', FieldValue: 'Choice 1' },
  { FieldName: 'MultiChoiceField', FieldValue: 'Choice 1;#Choice 2' },
  // Hyperlink or picture (after URL a description can go after ', ' delimeter)
  { FieldName: 'HyperlinkField', FieldValue: 'https://arvosys.com, ARVO Systems' },
  // Lookups fields (single and multi-valued)
  { FieldName: 'LookupField', FieldValue: '2' /* Item ID as string */ },
  { FieldName: 'MutliLookupField', FieldValue: [3, 4, 5].map(id => `${id};#`).join(';#') },
  // Mamnaged metadata fields (single and multi-valued)
  { FieldName: 'SingleMMDField', FieldValue: 'Department 2|220a3627-4cd3-453d-ac54-34e71483bb8a;' },
  { FieldName: 'MultiMMDField', FieldValue: 'Department 2|220a3627-4cd3-453d-ac54-34e71483bb8a;Department 3|700a1bc3-3ef6-41ba-8a10-d3054f58db4b;' }
]);

Happy coding!

jeudi 26 juin 2014

Group Items on Their Folder Name Inside a SharePoint Library


As you probably will know, folders could not be used in views to group documents. You could only group documents on their metadata.
Group Documents
Group Documents
A possible solution could be to add a new metadata field to the content type and manually add the folder name as the metadata value. It is very easy to add and requires no custom development, but it requires an extra manual step from the document creator.
This manual step can also be automated by a SharePoint 2010 Document library functionality called Column default value settings. It can be found on the document library settings page under the General settings section.
The Column default value settings enable you to define a default value for a metadata column per folder.
Default column value
Default column value

Approach

  • Go to the document library settings;
  • Create a new column called: Folder name (Single line of text);
  • Click on Column default value settings under the General settings section;
    Culumn default value settings
    Culumn default value settings
  • On the left side you will see your folders, and on the right site the columns for which you could give up a default value;
    Folders, columns
    Folders, columns
  • Click on the folder name, and after that on the column name;
    Default column value
    Default column value
  • Click Use this default value, and fill in the folder value and click OK;
  • Repeat this process for each folder.
Now when you upload a document to a folder, the Folder name column will automatically get the default value.
To prevent users being able to fill in their own value, you could hide the Folder name columnfrom the new and edit forms.
Hidde column from forms
Hidde column from forms

Result

Group by on folder name
Group by on folder name

Attention: SharePoint Foundation

The Column default value functionality is not available in SharePoint Foundation.

Missing “Destination folder” on upload document form

When uploading documents into a document library with folders, you normally see the following screen:

Problem On one of our sites the Destination Folder was not available. After some investigating I found that the site where it didn’t work, was created using the “Blank site” template. 
Solution Since we used the “Blank site” template, some features do not get activated by default.
I found out that the feature that is responsible for the “Destination Folder” is the “Metadata Navigation and Filtering”feature.
image
After activating the solution, the Destination Folder became available. Note that if you turn this feature off, existing libraries will be able to select a destination folder, as where newly created document libraries will not be able to use this feature.

jeudi 27 mars 2014

Get élement from Liste sharepoint avec une CAML Query

  public static String LoadDocById(int idDoc)
  {
            String etape = "Debut Methode";
            SPList list = SPContext.Current.Web.Site.RootWeb.Lists["Docs"];
            if (list != null)
            {
                etape = "Litse non null";
string caml = @"<Where><Eq><FieldRef Name='ID' /><Value                     Type='Text'>2428</Value></Eq></Where>";

                SPQuery qry = new SPQuery();
                qry.Query = caml;
                SPListItemCollection items = list.GetItems(qry);
                            

foreach (SPListItem item in items)
                    {
                        String nomFichier = "";
                        if (item2["Nom"] != null)
                        {
                            nomFichier = item["Nom"].ToString();
                        }

                        if (item2["ID"] != null)
                        {
                            nomFichier = item["ID"].ToString();
                        }
                    }
                }

 return etape;

            }

mardi 11 mars 2014

A CAML Query Quick Reference

Single Line of Text

Value TypeText
Example<Query><Where><Eq><FieldRef Name="Title" /><Value Type="Text">Hello World!</Value></Eq></Where></Query>
NotesThis is one of the simplest queries. The example selects items with a title equal to “Hello World!”

Multiple Lines of Text

Value TypeText
Example<Query><Where><Contains><FieldRef Name="Body" /><Value Type="Text"><![CDATA[</a>]]></Value></Contains></Where></Query>
NotesIf this is a Rich Text field, you can use <![CDATA[]]> around the value to prevent parsing errors when passing HTML into the query. Alternatively, you can encode the HTML by replacing < with &lt;, > with &gt;, and " with &quot;. This query uses <Contains> to return any items that contain a hyperlink in the body field by looking for the closing </a> tag.

Person or Group (By Name)

Value TypeText
Example<Query><Where><Eq><FieldRef Name="Author" /><Value Type="Text">Josh McCarty</Value></Eq></Where></Query>
NotesThis will look for items created by any user with “Josh McCarty” in the Name field of the User Information list. If more than one person has the same display name in the user list, it will select items created by all users with that name.

Person or Group (By ID)

Value TypeInteger
Example<Query><Where><Eq><FieldRef Name="Author" LookupId="TRUE" /><Value Type="Integer"><UserID /></Value></Eq></Where></Query>
NotesBy adding LookupId="TRUE" to the <FieldRef /> and using <UserID /> as the value, the query will filter based on the current user. You can also pass the ID of a specific user in place of <UserID /> (e.g. <Value Type="Integer">283</Value>) if you don’t want to filter by the current user. IDs are always unique, so this method ensures that only one user is a valid value.

Lookup (By Text)

Value TypeLookup
Example<Query><Where><Eq><FieldRef Name="State" /><Value Type="Lookup">Arizona</Value></Eq></Where></Query>
NotesThis will look for items with “Arizona” in the State field. If more than one state has the same display name (not likely in this example, but for other lookups it could happen), it will return items from all states with that display name.

Lookup (By ID)

Value TypeLookup
Example<Query><Where><Eq><FieldRef Name="State" LookupId="TRUE" /><Value Type="Lookup">4</Value></Eq></Where></Query>
NotesBy adding LookupId="TRUE" to the <FieldRef />, the query will filter based on the ID of the lookup rather than the text value. IDs are always unique, so this method ensures that only one state is a valid value.

Date (Day Only)

Value TypeDate
Example<Query><Where><Eq><FieldRef Name="Created" /><Value Type="DateTime">2012-01-10</Value></Eq></Where></Query>
NotesThis type of query seems to work whether the value type is set to DateTime or just Date as long as the value is formatted properly (yyyy-mm-dd). It also works if <Today /> is used as the value (you can offset the current date; e.g. use <Today OffsetDays="-7" /> for 7 days ago). <Today />.

mercredi 12 février 2014

Executer Sharepoint Designer avec un compte précis


1.lancer cmd
2. tapez la commande suivante : runas /user:username "chemin du exe"
à savoir "chemin du fichier = C:\Program Files\Microsoft Office\Office15\SPDESIGN.exe"
3. entrez votre password

lundi 27 janvier 2014

Session lost problem after Response.Redirect

If you create a session like this and redirect the user to some other page, the session will lost.

Session["UserId"] = "User1";
Response.Redirect("YourPage.aspx");

This is because of the working of session and Response.Redirect, Lets go through.

" When you create a new session (that is, the first time you write to a Session variable), ASP.NET sets a volatile cookie on the client that contains the session token. On all subsequent requests, and as long as the server session and the client cookie have not expired, ASP.NET can look at this cookie and find the right session.
Now, what Redirect does is to send a special header to the client so that it asks the server for a different page than the one it was waiting for. Server-side, after sending this header, Redirect ends the response. This is a very violent thing to do. Response.End actually stops the execution of the page wherever it is using a ThreadAbortException.
What happens really here is that the session token gets lost in the battle.
There are a few things you can do to solve this problem.
First, in the case of the forms authentication, we already provide a special redirect method: FormsAuthentication.RedirectFromLoginPage. This method is great because, well, it works, and also because it will return the user to the page he was asking for in the first place, and not always default. This means that the user can bookmark protected pages on the site, among other things. " - Bertrand Le Roy
Another thing you can do is use the overloaded version of Redirect:

Response.Redirect("YourPage.aspx", false);

This does not abort the thread and thus conserve the session token. Actually, this overload is used internally by RedirectFromLoginPage.

mardi 21 janvier 2014

Créer son premier Projet Sharepoint

On commence par créer un empty sharepoint project

ensuite on met l'adresse du site dans lequel on va déployer:

et pour finir le résultat sera le suivant:

et puis on créera notre 1ère webpart clique droit sur le projet Ajouter -> Nouvel élément -> Visual WebPart et on lui donne un nom :

Ensuite on ouvre le sharepoint designer et on créé une page de webpart et on associe notre webpart qu'on vient de créer. pour plus de détails n'hésitez pas à laisser des commentaires.

mardi 29 octobre 2013

Error : The file you are attempting to save or retrieve has been blocked from this Web site by the server administrators.

Error : The file you are attempting to save or retrieve has been blocked from this Web site by the server administrators.
Answer :
1. Start Central Administration.
2. Click Security, and then click "Define Blocked file types"
3. On the Blocked File Types page, click the Web application that you want to configure in the Web Application box.
4. Remove the file name extension from the list of blocked file types.
5. Click OK.

vendredi 11 octobre 2013

Sharepoint 2010 : Comment créer une liste externe vers SQL Server avec Sharepoint Designer

Sharepoint 2010 inclut une fonctionnalité qui s’appelle le « Business Connectivity Services » (BCS) qui permet à Sharepoint de se connecter à des sources de données externes. Cette fonctionnalité est d’ailleurs incluse dans la version gratuite Sharepoint Foundation.  À l’intérieur de cet article, nous allons regarder comment créer simplement une liste externe qui exploite les données d’une banque de données SQL. Comme toujours dans Sharepoint, il est possible de faire cela de plusieurs manières, mais afin de demeurer le plus simple possible, nous utiliserons Sharepoint Designer 2010.
Pour le bien de l’exemple, nous utiliserons la vue « NTEventLog » de la banque de données « WSS_Logging ». Cette banque contient les événements du journal des événements de Windows.
1-     Ouvrir un site Sharepoint dans Sharepoint Designer.
2-     Dans le panneau de navigation de gauche, sélectionner « Types de contenu externe »

3-     Cliquer le bouton du ruban « Type de contenu externe »


4-     Changer le nom et le nom complet et cliquer sur le lien « Cliquez ici pour découvrir les sources de données externes et définir les opérations »


5-     Cliquer sur le bouton « Ajouter une connexion »


6-     Sélectionner « SQL Server » dans la liste « Type de source de données »


7-     Entrer le nom du serveur et le nom de la banque de données SQL

Lorsque la source de données sera configurée, vous verrez apparaître votre banque de donnée dans l’onglet « Explorateur de source de données ».

8-     Naviguer jusqu’à la table ou la vue que vous désirez exploiter. Utiliser le bouton droit de la souris pour faire apparaître le menu contextuel. À partir de cet endroit, vous devez sélectionner quelles opérations seront disponible. Toujours dans l’idée de rester le plus simple possible, nous allons choisir « Créer toutes les opérations ».

9-     Sharepoint va prendre quelques temps pour créer l’opération et par la suite, l’écran « Propriétés de l’opération » apparaît. Cliquer sur « Suivant ».

10-     À cet endroit, vous devez spécifiez un identificateur. Pour le bien de l’exemple, nous sélectionnerons « RowId ». Par la suite cliquer sur « Terminer » pour compléter après quelques secondes Sharepoint aura terminé la création des opérations.


11-     Par la suite, il ne vous reste qu’à sauvegarder votre source de données en cliquant sur l’icône de la disquette dans le coin supérieur gauche.

12-     Maintenant, dans le panneau de navigation de gauche sélectionner « Listes et bibliothèques » puis cliquer sur le bouton « Liste externe » dans le ruban.


13-     Sélectionner le type de contenu externe et cliquer sur « OK »

14-     Entrer le nom et la description de la liste

15-     Voilà, la liste est maintenant disponible.

16-     Cliquer sur le nom de la liste et par la suite sur le bouton du ruban « Aperçu dans le navigateur » pour voir la liste tel que présentée ci-dessous :
Voilà, c’est tout et c’est aussi simple que cela.

vendredi 27 septembre 2013

Using DataPager in ListView

If the DataSource is not known statically at design time, the DataPager may not work correctly. The following error could be expected to happen when you click on the link provided by DataPager at the second time:
Failed to load viewstate. The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request. For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial request.
This problem occurs because the DataPager has no idea how to perform or calculate paging for you without knowing what page is supposed to display (i.e., StartIndex, and MaximuumRows in the page) when the DataSource is only known at runtime. Thus, you need to provide this missing piece of information to the DataPager before databinding.
Under Google search, you may find that quite a few people implemented the PreRender event of DataPager to perform databinding. Unfortunately, it doesn't work for this scenario. You can bind the data at DataPager's PreRender event but you are unable to supply paging properties to DataPager as mentioned above. Both StartRowIndex and MaximumRows properties are needed to set for paging before databinding. This problem took me a few hours to resolve. It turns out that the solution is very simple.
The Solution: You should add and implement the PagePropertiesChanging event of ListView. The PagePropertiesChangingEventArgs from the event argument will provide all your needy paging properties (StartRowIndex and MaximumRows) so that you can supply them to the DataPager.

protected void ListView1_PagePropertiesChanging(object sender, PagePropertiesChangingEventArgs e) { this.DataPage1.SetPageProperties(e.StartRowIndex, e.MaximumRows, false); BindData();
 // set DataSource to ListView and call DataBind() of ListView
 }

 If the DataPager is placed inside the ListView, do this: 
 
protected void ListView1_PagePropertiesChanging(object sender, 
PagePropertiesChangingEventArgs e) {
      ListView lv = sender as ListView;
      DataPager pager = lv.FindControl("DataPage1") as DataPager;
      pager.SetPageProperties(e.StartRowIndex, e.MaximumRows, false);
      BindData(); 
// set DataSource to ListView and call DataBind() of ListView
    } 

dimanche 22 septembre 2013

SharePoint DateTime Control Validation


Ce code contrôle que la date est obligatoire et valide


                
 <asp:RequiredFieldValidator ID="RequiredFieldValidator18" runat="server" ErrorMessage="La date ouverture des plis est obligatoire."  Text="*"              ControlToValidate="dateOuverturePlisDateTimeControl$dateOuverturePlisDateTimeControlDate" ValidationGroup="group1" Display="Dynamic" ForeColor="Red" ></asp:RequiredFieldValidator>
            
<asp:CompareValidator ID="valDate" runat="server" ForeColor="Red" ControlToValidate="dateOuverturePlisDateTimeControl$dateOuverturePlisDateTimeControlDate"
                 Type="Date" Operator="DataTypeCheck" ErrorMessage="Entrez une date valide" Display="Dynamic"  ValidationGroup="group1" /> 
  <SharePoint:DateTimeControl ID="dateOuverturePlisDateTimeControl"  runat="server" Calendar="GregorianMEFrench"  />