Dynamic DataSource for Droplist in Content EditorRestrict Content Editor Language Dropdown OptionsHow do you extend the item:new command without breaking a previous patch for it?Broken Links when using TokensMixed Content: The page at was loaded over HTTPS, but requested an insecure XMLHttpRequest endpointSitecore 9 - Authors accessing profile information for content itemsGetting a “Resource you are looking for has been removed” error in the datasource selection dialogPre-customize My Toolbar for users of a given role or domain?Different datasource for adding and changing rendering component contentContent and Experience Editor custom buttons - only show for certain roles

A word that refers to saying something in an attempt to anger or embarrass someone into doing something that they don’t want to do?

Pushing the e-pawn

What should I consider when deciding whether to delay an exam?

Garage door sticks on a bolt

How to prevent pickpocketing in busy bars?

Do interval ratios take overtones into account or solely the fundamental frequency?

Calculate the Ultraradical

What is Weapon Handling?

If a spaceship ran out of fuel somewhere in space between Earth and Mars, does it slowly drift off to the Sun?

Lost passport which have valid student visa but I make new passport unable paste

Why does Captain Marvel in the MCU not have her sash?

Sci-fi movie with one survivor and an organism(?) recreating his memories

Received a package but didn't order it

Concerning a relationship in the team

Can I target any number of creatures, even if the ability would have no effect?

What happens to a net with the Returning Weapon artificer infusion after it hits?

How deep is the liquid in a half-full hemisphere?

Assembly of PCBs containing a mix of SMT and thru-hole parts?

Why is the Common Agricultural Policy unfavourable to the UK?

Why, even after his imprisonment, people keep calling Hannibal Lecter "Doctor"?

Is there a relationship between prime numbers and music?

Does the app TikTok violate trademark?

Is the illusion created by Invoke Duplicity affected by difficult terrain?

How can I model regression with an asymmetric loss function?



Dynamic DataSource for Droplist in Content Editor


Restrict Content Editor Language Dropdown OptionsHow do you extend the item:new command without breaking a previous patch for it?Broken Links when using TokensMixed Content: The page at was loaded over HTTPS, but requested an insecure XMLHttpRequest endpointSitecore 9 - Authors accessing profile information for content itemsGetting a “Resource you are looking for has been removed” error in the datasource selection dialogPre-customize My Toolbar for users of a given role or domain?Different datasource for adding and changing rendering component contentContent and Experience Editor custom buttons - only show for certain roles






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








2















I have a Droplist for Approvers and the DataSource of Droplist to /SharedData/Approvers.



I don't want the current user to have his own name in the list.
For example, DataSource List is having A, B and C



When A logs in, it should show B and C but not A. Or it should be validated when A selects himself as Approver.



Any idea?










share|improve this question
































    2















    I have a Droplist for Approvers and the DataSource of Droplist to /SharedData/Approvers.



    I don't want the current user to have his own name in the list.
    For example, DataSource List is having A, B and C



    When A logs in, it should show B and C but not A. Or it should be validated when A selects himself as Approver.



    Any idea?










    share|improve this question




























      2












      2








      2








      I have a Droplist for Approvers and the DataSource of Droplist to /SharedData/Approvers.



      I don't want the current user to have his own name in the list.
      For example, DataSource List is having A, B and C



      When A logs in, it should show B and C but not A. Or it should be validated when A selects himself as Approver.



      Any idea?










      share|improve this question
















      I have a Droplist for Approvers and the DataSource of Droplist to /SharedData/Approvers.



      I don't want the current user to have his own name in the list.
      For example, DataSource List is having A, B and C



      When A logs in, it should show B and C but not A. Or it should be validated when A selects himself as Approver.



      Any idea?







      sitecore-client content-editor validation






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 6 hours ago









      Hishaam Namooya

      7,0521 gold badge8 silver badges28 bronze badges




      7,0521 gold badge8 silver badges28 bronze badges










      asked 8 hours ago









      user3621user3621

      1096 bronze badges




      1096 bronze badges























          1 Answer
          1






          active

          oldest

          votes


















          4
















          It is possible via both a custom field implementation or field validation. Below is the code for both ways.



          Solution 1 - A Custom Validation



          You should implement a class which will extend the StandardValidator. The code snippet is provided below to create a custom validation for the droplist.



          [Serializable]
          public class UserValidation : StandardValidator

          protected override ValidatorResult Evaluate()

          var selectedValue = ControlValidationValue;

          var username = Context.User.LocalName;

          if (!selectedValue.IsNullOrEmpty() && selectedValue.Equals(username))

          Text = GetText($"Field GetFieldDisplayName() cannot select your own name");
          return ValidatorResult.FatalError;


          return ValidatorResult.Valid;


          protected override ValidatorResult GetMaxValidatorResult()

          return GetFailedResult(ValidatorResult.Error);


          public override string Name => "User Validator";



          In the code above, I have use the LocalName property. This property will return me only the name. Example, Admin.



          Note that this piece of code will validate the username against the item name. It is feasible check the username against a field on the items from the list but it will require additional code to retrieve the selected item then read the field.



          Once you have deployed the above code, you will need to create a new validation item under the path /sitecore/system/Settings/Validation Rules/Field Rules.



          enter image description here



          Change the Type to match your namespace. Also, you need to assign the newly created validation rule to the field.



          Solution 2 - A Custom Field



          You can implement a custom droplist which extend the ValueLookupEx from the namespace Sitecore.Shell.Applications.ContentEditor in the Sitecore.Kernel.dll. The purpose will be to remove the current user from the list of items if it matches.



          public class CustomDroplist : ValueLookupEx

          protected override Item[] GetItems(Item current)

          var items = base.GetItems(current);

          var username = Sitecore.Context.User.LocalName;

          var resultItems = items.Where(w => !w.Name.Equals(username)).ToArray();

          return resultItems;




          Once implemented, deploy the code and load the content editor. Then, switch the database to core and navigate to the path /sitecore/system/Field types/List Types and create a new field using the template Template field type.



          enter image description here



          Update the assembly and class with yours.



          Outcome



          enter image description here






          share|improve this answer



























            Your Answer








            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "664"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );














            draft saved

            draft discarded
















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsitecore.stackexchange.com%2fquestions%2f22221%2fdynamic-datasource-for-droplist-in-content-editor%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            4
















            It is possible via both a custom field implementation or field validation. Below is the code for both ways.



            Solution 1 - A Custom Validation



            You should implement a class which will extend the StandardValidator. The code snippet is provided below to create a custom validation for the droplist.



            [Serializable]
            public class UserValidation : StandardValidator

            protected override ValidatorResult Evaluate()

            var selectedValue = ControlValidationValue;

            var username = Context.User.LocalName;

            if (!selectedValue.IsNullOrEmpty() && selectedValue.Equals(username))

            Text = GetText($"Field GetFieldDisplayName() cannot select your own name");
            return ValidatorResult.FatalError;


            return ValidatorResult.Valid;


            protected override ValidatorResult GetMaxValidatorResult()

            return GetFailedResult(ValidatorResult.Error);


            public override string Name => "User Validator";



            In the code above, I have use the LocalName property. This property will return me only the name. Example, Admin.



            Note that this piece of code will validate the username against the item name. It is feasible check the username against a field on the items from the list but it will require additional code to retrieve the selected item then read the field.



            Once you have deployed the above code, you will need to create a new validation item under the path /sitecore/system/Settings/Validation Rules/Field Rules.



            enter image description here



            Change the Type to match your namespace. Also, you need to assign the newly created validation rule to the field.



            Solution 2 - A Custom Field



            You can implement a custom droplist which extend the ValueLookupEx from the namespace Sitecore.Shell.Applications.ContentEditor in the Sitecore.Kernel.dll. The purpose will be to remove the current user from the list of items if it matches.



            public class CustomDroplist : ValueLookupEx

            protected override Item[] GetItems(Item current)

            var items = base.GetItems(current);

            var username = Sitecore.Context.User.LocalName;

            var resultItems = items.Where(w => !w.Name.Equals(username)).ToArray();

            return resultItems;




            Once implemented, deploy the code and load the content editor. Then, switch the database to core and navigate to the path /sitecore/system/Field types/List Types and create a new field using the template Template field type.



            enter image description here



            Update the assembly and class with yours.



            Outcome



            enter image description here






            share|improve this answer





























              4
















              It is possible via both a custom field implementation or field validation. Below is the code for both ways.



              Solution 1 - A Custom Validation



              You should implement a class which will extend the StandardValidator. The code snippet is provided below to create a custom validation for the droplist.



              [Serializable]
              public class UserValidation : StandardValidator

              protected override ValidatorResult Evaluate()

              var selectedValue = ControlValidationValue;

              var username = Context.User.LocalName;

              if (!selectedValue.IsNullOrEmpty() && selectedValue.Equals(username))

              Text = GetText($"Field GetFieldDisplayName() cannot select your own name");
              return ValidatorResult.FatalError;


              return ValidatorResult.Valid;


              protected override ValidatorResult GetMaxValidatorResult()

              return GetFailedResult(ValidatorResult.Error);


              public override string Name => "User Validator";



              In the code above, I have use the LocalName property. This property will return me only the name. Example, Admin.



              Note that this piece of code will validate the username against the item name. It is feasible check the username against a field on the items from the list but it will require additional code to retrieve the selected item then read the field.



              Once you have deployed the above code, you will need to create a new validation item under the path /sitecore/system/Settings/Validation Rules/Field Rules.



              enter image description here



              Change the Type to match your namespace. Also, you need to assign the newly created validation rule to the field.



              Solution 2 - A Custom Field



              You can implement a custom droplist which extend the ValueLookupEx from the namespace Sitecore.Shell.Applications.ContentEditor in the Sitecore.Kernel.dll. The purpose will be to remove the current user from the list of items if it matches.



              public class CustomDroplist : ValueLookupEx

              protected override Item[] GetItems(Item current)

              var items = base.GetItems(current);

              var username = Sitecore.Context.User.LocalName;

              var resultItems = items.Where(w => !w.Name.Equals(username)).ToArray();

              return resultItems;




              Once implemented, deploy the code and load the content editor. Then, switch the database to core and navigate to the path /sitecore/system/Field types/List Types and create a new field using the template Template field type.



              enter image description here



              Update the assembly and class with yours.



              Outcome



              enter image description here






              share|improve this answer



























                4














                4










                4









                It is possible via both a custom field implementation or field validation. Below is the code for both ways.



                Solution 1 - A Custom Validation



                You should implement a class which will extend the StandardValidator. The code snippet is provided below to create a custom validation for the droplist.



                [Serializable]
                public class UserValidation : StandardValidator

                protected override ValidatorResult Evaluate()

                var selectedValue = ControlValidationValue;

                var username = Context.User.LocalName;

                if (!selectedValue.IsNullOrEmpty() && selectedValue.Equals(username))

                Text = GetText($"Field GetFieldDisplayName() cannot select your own name");
                return ValidatorResult.FatalError;


                return ValidatorResult.Valid;


                protected override ValidatorResult GetMaxValidatorResult()

                return GetFailedResult(ValidatorResult.Error);


                public override string Name => "User Validator";



                In the code above, I have use the LocalName property. This property will return me only the name. Example, Admin.



                Note that this piece of code will validate the username against the item name. It is feasible check the username against a field on the items from the list but it will require additional code to retrieve the selected item then read the field.



                Once you have deployed the above code, you will need to create a new validation item under the path /sitecore/system/Settings/Validation Rules/Field Rules.



                enter image description here



                Change the Type to match your namespace. Also, you need to assign the newly created validation rule to the field.



                Solution 2 - A Custom Field



                You can implement a custom droplist which extend the ValueLookupEx from the namespace Sitecore.Shell.Applications.ContentEditor in the Sitecore.Kernel.dll. The purpose will be to remove the current user from the list of items if it matches.



                public class CustomDroplist : ValueLookupEx

                protected override Item[] GetItems(Item current)

                var items = base.GetItems(current);

                var username = Sitecore.Context.User.LocalName;

                var resultItems = items.Where(w => !w.Name.Equals(username)).ToArray();

                return resultItems;




                Once implemented, deploy the code and load the content editor. Then, switch the database to core and navigate to the path /sitecore/system/Field types/List Types and create a new field using the template Template field type.



                enter image description here



                Update the assembly and class with yours.



                Outcome



                enter image description here






                share|improve this answer













                It is possible via both a custom field implementation or field validation. Below is the code for both ways.



                Solution 1 - A Custom Validation



                You should implement a class which will extend the StandardValidator. The code snippet is provided below to create a custom validation for the droplist.



                [Serializable]
                public class UserValidation : StandardValidator

                protected override ValidatorResult Evaluate()

                var selectedValue = ControlValidationValue;

                var username = Context.User.LocalName;

                if (!selectedValue.IsNullOrEmpty() && selectedValue.Equals(username))

                Text = GetText($"Field GetFieldDisplayName() cannot select your own name");
                return ValidatorResult.FatalError;


                return ValidatorResult.Valid;


                protected override ValidatorResult GetMaxValidatorResult()

                return GetFailedResult(ValidatorResult.Error);


                public override string Name => "User Validator";



                In the code above, I have use the LocalName property. This property will return me only the name. Example, Admin.



                Note that this piece of code will validate the username against the item name. It is feasible check the username against a field on the items from the list but it will require additional code to retrieve the selected item then read the field.



                Once you have deployed the above code, you will need to create a new validation item under the path /sitecore/system/Settings/Validation Rules/Field Rules.



                enter image description here



                Change the Type to match your namespace. Also, you need to assign the newly created validation rule to the field.



                Solution 2 - A Custom Field



                You can implement a custom droplist which extend the ValueLookupEx from the namespace Sitecore.Shell.Applications.ContentEditor in the Sitecore.Kernel.dll. The purpose will be to remove the current user from the list of items if it matches.



                public class CustomDroplist : ValueLookupEx

                protected override Item[] GetItems(Item current)

                var items = base.GetItems(current);

                var username = Sitecore.Context.User.LocalName;

                var resultItems = items.Where(w => !w.Name.Equals(username)).ToArray();

                return resultItems;




                Once implemented, deploy the code and load the content editor. Then, switch the database to core and navigate to the path /sitecore/system/Field types/List Types and create a new field using the template Template field type.



                enter image description here



                Update the assembly and class with yours.



                Outcome



                enter image description here







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 7 hours ago









                Hishaam NamooyaHishaam Namooya

                7,0521 gold badge8 silver badges28 bronze badges




                7,0521 gold badge8 silver badges28 bronze badges































                    draft saved

                    draft discarded















































                    Thanks for contributing an answer to Sitecore Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsitecore.stackexchange.com%2fquestions%2f22221%2fdynamic-datasource-for-droplist-in-content-editor%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Invision Community Contents History See also References External links Navigation menuProprietaryinvisioncommunity.comIPS Community ForumsIPS Community Forumsthis blog entry"License Changes, IP.Board 3.4, and the Future""Interview -- Matt Mecham of Ibforums""CEO Invision Power Board, Matt Mecham Is a Liar, Thief!"IPB License Explanation 1.3, 1.3.1, 2.0, and 2.1ArchivedSecurity Fixes, Updates And Enhancements For IPB 1.3.1Archived"New Demo Accounts - Invision Power Services"the original"New Default Skin"the original"Invision Power Board 3.0.0 and Applications Released"the original"Archived copy"the original"Perpetual licenses being done away with""Release Notes - Invision Power Services""Introducing: IPS Community Suite 4!"Invision Community Release Notes

                    Canceling a color specificationRandomly assigning color to Graphics3D objects?Default color for Filling in Mathematica 9Coloring specific elements of sets with a prime modified order in an array plotHow to pick a color differing significantly from the colors already in a given color list?Detection of the text colorColor numbers based on their valueCan color schemes for use with ColorData include opacity specification?My dynamic color schemes

                    Ласкавець круглолистий Зміст Опис | Поширення | Галерея | Примітки | Посилання | Навігаційне меню58171138361-22960890446Bupleurum rotundifoliumEuro+Med PlantbasePlants of the World Online — Kew ScienceGermplasm Resources Information Network (GRIN)Ласкавецькн. VI : Літери Ком — Левиправивши або дописавши її