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;
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
add a comment
|
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
add a comment
|
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
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
sitecore-client content-editor validation
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
add a comment
|
add a comment
|
1 Answer
1
active
oldest
votes
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
.
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
.
Update the assembly and class with yours.
Outcome
add a comment
|
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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
.
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
.
Update the assembly and class with yours.
Outcome
add a comment
|
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
.
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
.
Update the assembly and class with yours.
Outcome
add a comment
|
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
.
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
.
Update the assembly and class with yours.
Outcome
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
.
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
.
Update the assembly and class with yours.
Outcome
answered 7 hours ago
Hishaam NamooyaHishaam Namooya
7,0521 gold badge8 silver badges28 bronze badges
7,0521 gold badge8 silver badges28 bronze badges
add a comment
|
add a comment
|
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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