0

I wrote two event revicer. On base on Web scope - this frature creat page and shom on them all list field by their display name, user select interesting to him field and can they use in mail template.

foreach (SPField field in list.Fields)
{
    if ((!field.Hidden && !field.ReadOnlyField && field.Title != "Typ zawartości" && field.Title != "Załączniki") || ((field.Title == "Zmodyfikowane" && !field.Hidden) || (field.Title == "Utworzony" && !field.Hidden) || field.Title == "Utworzony przez" || field.Title == "Zmodyfikowane przez"))
    {
        if (field.Type == SPFieldType.Boolean || field.Type == SPFieldType.Calculated || field.Type == SPFieldType.Choice || field.Type == SPFieldType.Computed || field.Type == SPFieldType.Currency || field.Type == SPFieldType.MultiChoice || field.Type == SPFieldType.Number || field.Type == SPFieldType.Text || field.Type == SPFieldType.URL || field.Type == SPFieldType.Note)
        {
            BulletedList1.Items.Add($"{field.Title} -> [[{field.Title}]]");
        }
        if (field.Type == SPFieldType.User)
        {
            BulletedList2.Items.Add($"{field.Title} -> [[{field.Title}.imie]], [[{field.Title}.imie_nazwisko]]");
        }
        if (field.Type == SPFieldType.DateTime)
        {
            BulletedList3.Items.Add($"{field.Title} -> [[{field.Title}.data]], [[{field.Title}.data_czas]]");
        }
    }
}

And the second event revicer for WebApplication scope is for job timer. Code read our mail tempale and replace field thier vaule. But the forach on aspx page return fieled by their "translated" display name and the same loop i timer job class retune "no-translated" filen in their original name. For example the default Title or Author, in polish the **Title I chaneged on Adres IP and in polish the Author is Utworzony przez. So for few filed I can do simply replace becasue the Title don't match the Adres IP.

Dictionary<string, string> fieldsValues = new Dictionary<string, string>();
foreach (SPField f in targetList.Fields)
{
    if ((!f.Hidden && !f.ReadOnlyField && f.Title != "Typ zawartości" && f.Title != "Załączniki") || ((f.Title == "Zmodyfikowane" && !f.Hidden) || (f.Title == "Utworzony" && !f.Hidden) || f.Title == "Utworzony przez" || f.Title == "Zmodyfikowane przez"))
    {
...
    }

So, how i can reach the "translated" display name for field from the place where started the code? I can save somewhere the "no-translated" or static name and my dispaly name tha i can see in aspx pages and them compare by or some anothe way by i prefer get the nam when i looping list.Field.

0

Field staticname is unique so you could store mapping for fields' staticname with your "translated" names somewehre.

https://docs.microsoft.com/en-us/dotnet/api/microsoft.sharepoint.spfield.staticname?view=sharepoint-server

|improve this answer|||||

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.