7

I have a need to set a specific users content editing parameters, specifically I need to set "paste as text" as a default for some users. I have been unable to parse out what needs to be done from the AppData. Looking for any help or direction. I need to be able to control this through the Core Service, not the GUI.

1
  • Hi James and welcome to the Tridion community! Jun 3 '13 at 15:58
5

I was able to do this through CoreService with the following code:

ApplicationData[] arrayAd = new ApplicationData[client.ReadAllApplicationData(userElement.Attribute("ID").Value).Count()];
arrayAd = client.ReadAllApplicationData(userElement.Attribute("ID").Value);

    foreach (ApplicationData ad in arrayAd)
    {
        if (ad.ApplicationId.Equals("cme:UserPreferences"))
        {
            apData = System.Text.Encoding.Unicode.GetString(ad.Data);

            //<DefaultSpecialPasteOption>1</DefaultSpecialPasteOption>
            if (apData.Contains("DefaultSpecialPasteOption"))
                apData = Regex.Replace(apData, "<DefaultSpecialPasteOption>.</DefaultSpecialPasteOption>", "<DefaultSpecialPasteOption>4</DefaultSpecialPasteOption>");
            else
                apData += "<DefaultSpecialPasteOption>4</DefaultSpecialPasteOption>";

            ad.Data = System.Text.Encoding.Unicode.GetBytes(apData);

            hasPreference = true;

            break;
        }
    }

    if (!hasPreference)
        userInfo.Append(userElement.Attribute("Title").Value + " does not have UserPreferences\n");

    client.SaveApplicationData(userElement.Attribute("ID").Value, arrayAd);

This allowed me to set the user default paste option in their cme:UserPreferences. This assumes that they have logged into the system before to set at least their language and search result count.

Now that we have updated all existing users...we will apply this to an event system on new user creation...or try to find the config that sets the default and update it.

Hope this helps.

1
  • 1
    Do keep in mind that application data like this may be changed without notice in the future (read: it's not considered a part of any public API). That said, it's probably the best solution to your particular issue. You should probably ask for this ability to be added to the product, too :) Jun 7 '13 at 14:22
5

What you're asking for, i.e. to control a dropdown default value in the Rich Text Toolbar via the Core Service, is not possible. This is something you need to accomplish via the Anguilla API in a GUI Extension.

However, as per Nuno's comment, you should just be able to update the individual user's preference in the Dashboard:

enter image description here

5
  • At least in 2013 (can't check 2011) you can set this as a user preference in the dashboard, which implies it is linked to the profile somehow... I'd recommend comparing the user's app data before and after setting this option (Dashboard -> User Preferences -> Content Editing)
    – Nuno Linhares
    Jun 3 '13 at 16:06
  • Nuno is right. I've just verified in 2011 and it's the same as he describes for 2013. I've updated my answer to reflect this. Jun 3 '13 at 16:08
  • not sure if i explained this correctly. I want to set the Default Paste Special option radio button in the user preferences/content edition screen to a specific value for individual users , using the core-service when i create new users. Also having trouble finding the values for that data Jun 3 '13 at 16:19
  • need to not do this in the dashboard Jun 3 '13 at 16:26
  • What I meant was that if Tridion remembers this setting, then it stores it somewhere. If you store it in the same way, then it should also work
    – Nuno Linhares
    Jun 3 '13 at 17:05
0

According to the 2011SP1 core service API documentation this property is not exposed through the API (most likely because it is implemented as a GUI customization only) even though language ID and locale ID are.

Your only hope of automating this setting without using the GUI is to capture the difference between a user with this set and a user without and reverse engineer a solution BUT this will not be a supported way of working with the product as you're coding against a non-public and undocumented API...

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.