Make one of two sitecore content fields required?












2














I've been trying to find a way to make one of two fields valid and haven't come up with much. Is there a way to do this with custom field validators or is that just relevant to individual fields? The requirement is that one of two fields must be filled in, probably only one, but even if that's not possible, just having at least one filled in (and then there being a default in terms of which is used) would be acceptable, I suppose.










share|improve this question






















  • Nothing OOTB, but there may be a way to achieve what you are looking for via breaking up your content appropriately into different templates. For example, if you have two datasource templates, you could have different rules for validation. The author picks which template they want to use by selecting compatible renderings. It may help to know more about your specific authoring scenario to help guide you.
    – Jason St-Cyr
    yesterday
















2














I've been trying to find a way to make one of two fields valid and haven't come up with much. Is there a way to do this with custom field validators or is that just relevant to individual fields? The requirement is that one of two fields must be filled in, probably only one, but even if that's not possible, just having at least one filled in (and then there being a default in terms of which is used) would be acceptable, I suppose.










share|improve this question






















  • Nothing OOTB, but there may be a way to achieve what you are looking for via breaking up your content appropriately into different templates. For example, if you have two datasource templates, you could have different rules for validation. The author picks which template they want to use by selecting compatible renderings. It may help to know more about your specific authoring scenario to help guide you.
    – Jason St-Cyr
    yesterday














2












2








2







I've been trying to find a way to make one of two fields valid and haven't come up with much. Is there a way to do this with custom field validators or is that just relevant to individual fields? The requirement is that one of two fields must be filled in, probably only one, but even if that's not possible, just having at least one filled in (and then there being a default in terms of which is used) would be acceptable, I suppose.










share|improve this question













I've been trying to find a way to make one of two fields valid and haven't come up with much. Is there a way to do this with custom field validators or is that just relevant to individual fields? The requirement is that one of two fields must be filled in, probably only one, but even if that's not possible, just having at least one filled in (and then there being a default in terms of which is used) would be acceptable, I suppose.







content-editor validation






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked yesterday









Levi WallachLevi Wallach

556




556












  • Nothing OOTB, but there may be a way to achieve what you are looking for via breaking up your content appropriately into different templates. For example, if you have two datasource templates, you could have different rules for validation. The author picks which template they want to use by selecting compatible renderings. It may help to know more about your specific authoring scenario to help guide you.
    – Jason St-Cyr
    yesterday


















  • Nothing OOTB, but there may be a way to achieve what you are looking for via breaking up your content appropriately into different templates. For example, if you have two datasource templates, you could have different rules for validation. The author picks which template they want to use by selecting compatible renderings. It may help to know more about your specific authoring scenario to help guide you.
    – Jason St-Cyr
    yesterday
















Nothing OOTB, but there may be a way to achieve what you are looking for via breaking up your content appropriately into different templates. For example, if you have two datasource templates, you could have different rules for validation. The author picks which template they want to use by selecting compatible renderings. It may help to know more about your specific authoring scenario to help guide you.
– Jason St-Cyr
yesterday




Nothing OOTB, but there may be a way to achieve what you are looking for via breaking up your content appropriately into different templates. For example, if you have two datasource templates, you could have different rules for validation. The author picks which template they want to use by selecting compatible renderings. It may help to know more about your specific authoring scenario to help guide you.
– Jason St-Cyr
yesterday










2 Answers
2






active

oldest

votes


















1














There is nothing out of the box that will do this for you as far as I am aware and although you think it might be possible custom validation I don't think it is as the a validator works on only one field at a time so updates to the item would only have the updated data for that single field and not the other field. Therefore I think your only option here might be to use the item:saving event to validate the data there as mentioned by Richard Seal below:



Item validator access already stored data instead of newly inputed data



You need to be careful with this though to make sure it doesn't fire all of the time. Maybe you could check the template before running this validation or something.



Another related thread on SSE is here:
Apply field validations across fields






share|improve this answer





















  • Yeah, talking to another developer we already it seems have a custom validator that's doing something via the item:saving event, so I should be able to just tack this additional validation on to it. Thanks for helping me pinpoint the issue and solution.
    – Levi Wallach
    yesterday










  • No worries. I come across these kind of scenarios now and again and sometimes you can just handle the display logic in the controller before rendering and through Content Editor education. It would be useful if we could do this more easily with Custom Validators though.
    – Adam Seabridge
    yesterday



















3














I would recommend implementing a custom Item validation rule.




Note: This is different from a field validation, in that it validates the entire item instead of a single field.




1. Create custom validator



Create a new class that implements the Sitecore.Data.Validators.StandardValidator base class. In the Evaluate() method, get both fields and check to see if either of them has a value:



public class AtLeastOneFieldPopulatedValidator : StandardValidator
{
public override string Name => "At Least One Field Populated";

public AtLeastOneFieldPopulatedValidator() {}

public UrlCharacterValidator(SerializationInfo info, StreamingContext context) : base(info, context) {}

protected override ValidatorResult Evaluate()
{
Item item = base.GetItem();
if (item == null)
{
return ValidatorResult.Valid;
}
if (!string.IsNullOrEmpty(item["Field 1"]) || !string.IsNullOrEmpty(item["Field 2"]))
{
return ValidatorResult.Valid;
}
return base.GetFailedResult(ValidatorResult.CriticalError);
}

protected override ValidatorResult GetMaxValidatorResult()
{
return base.GetFailedResult(ValidatorResult.Error);
}
}


2. Create Validation Rule item



First, create a new Validation Rule (template /sitecore/templates/System/Validation/Validation Rule) item somewhere below this node:



/sitecore/system/Settings/Validation Rules/Item Rules



item validator tree




Important: Make sure you populate the Type field with your fully-qualified name of your custom validator's class (e.g. Custom.Services.AtLeastOneFieldPopulatedValidator, Custom.Services).




3. Associate your Validation Rule to your items



On the __Standard values of your item's template, show Standard Fields (View ribbon tab -> Standard fields) and add your Validation Rule to the appropriate validation fields. I recommend including it in all four.



(Optional) Extra credit: Add parameters



I've not tested this, but I'm sure there's a way to pass parameters using the Parameters field on the Validation Rule item. In these parameters, you could pass a list of the fields to check so your validator can be reused by creating multiple Validation Rule items in Sitecore.



parameters field






share|improve this answer























  • did you test this code? It would be great if it works but my understanding is that item["Field 2"] would not have a value at the point the validation for item["Field 1"] fires. This is mentioned in the SSE posts I've referenced in my answer.
    – Adam Seabridge
    yesterday










  • I believe this will be different, however, because this is an Item validator (not a field validator). I believe it still runs after every field is updated (I haven't dug through the CE JS to verify that), but it validates the entire item instead of just a single field.
    – Dan Sinclair
    yesterday










  • It also appears this is the same solution they used in the second SSE post you linked: "We additionally put an item validator on the component itself to prevent it from going through workflow."
    – Dan Sinclair
    yesterday










  • Ahr right, sorry yes it's not a field validator so the values should both be set. No worries then.
    – Adam Seabridge
    yesterday










  • @AdamSeabridge you point out a valid concern, though, that it was not clear. I've edited the answer to attempt to call that out more clearly.
    – Dan Sinclair
    yesterday











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/3.0/"u003ecc by-sa 3.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%2f15890%2fmake-one-of-two-sitecore-content-fields-required%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














There is nothing out of the box that will do this for you as far as I am aware and although you think it might be possible custom validation I don't think it is as the a validator works on only one field at a time so updates to the item would only have the updated data for that single field and not the other field. Therefore I think your only option here might be to use the item:saving event to validate the data there as mentioned by Richard Seal below:



Item validator access already stored data instead of newly inputed data



You need to be careful with this though to make sure it doesn't fire all of the time. Maybe you could check the template before running this validation or something.



Another related thread on SSE is here:
Apply field validations across fields






share|improve this answer





















  • Yeah, talking to another developer we already it seems have a custom validator that's doing something via the item:saving event, so I should be able to just tack this additional validation on to it. Thanks for helping me pinpoint the issue and solution.
    – Levi Wallach
    yesterday










  • No worries. I come across these kind of scenarios now and again and sometimes you can just handle the display logic in the controller before rendering and through Content Editor education. It would be useful if we could do this more easily with Custom Validators though.
    – Adam Seabridge
    yesterday
















1














There is nothing out of the box that will do this for you as far as I am aware and although you think it might be possible custom validation I don't think it is as the a validator works on only one field at a time so updates to the item would only have the updated data for that single field and not the other field. Therefore I think your only option here might be to use the item:saving event to validate the data there as mentioned by Richard Seal below:



Item validator access already stored data instead of newly inputed data



You need to be careful with this though to make sure it doesn't fire all of the time. Maybe you could check the template before running this validation or something.



Another related thread on SSE is here:
Apply field validations across fields






share|improve this answer





















  • Yeah, talking to another developer we already it seems have a custom validator that's doing something via the item:saving event, so I should be able to just tack this additional validation on to it. Thanks for helping me pinpoint the issue and solution.
    – Levi Wallach
    yesterday










  • No worries. I come across these kind of scenarios now and again and sometimes you can just handle the display logic in the controller before rendering and through Content Editor education. It would be useful if we could do this more easily with Custom Validators though.
    – Adam Seabridge
    yesterday














1












1








1






There is nothing out of the box that will do this for you as far as I am aware and although you think it might be possible custom validation I don't think it is as the a validator works on only one field at a time so updates to the item would only have the updated data for that single field and not the other field. Therefore I think your only option here might be to use the item:saving event to validate the data there as mentioned by Richard Seal below:



Item validator access already stored data instead of newly inputed data



You need to be careful with this though to make sure it doesn't fire all of the time. Maybe you could check the template before running this validation or something.



Another related thread on SSE is here:
Apply field validations across fields






share|improve this answer












There is nothing out of the box that will do this for you as far as I am aware and although you think it might be possible custom validation I don't think it is as the a validator works on only one field at a time so updates to the item would only have the updated data for that single field and not the other field. Therefore I think your only option here might be to use the item:saving event to validate the data there as mentioned by Richard Seal below:



Item validator access already stored data instead of newly inputed data



You need to be careful with this though to make sure it doesn't fire all of the time. Maybe you could check the template before running this validation or something.



Another related thread on SSE is here:
Apply field validations across fields







share|improve this answer












share|improve this answer



share|improve this answer










answered yesterday









Adam SeabridgeAdam Seabridge

6,0831148




6,0831148












  • Yeah, talking to another developer we already it seems have a custom validator that's doing something via the item:saving event, so I should be able to just tack this additional validation on to it. Thanks for helping me pinpoint the issue and solution.
    – Levi Wallach
    yesterday










  • No worries. I come across these kind of scenarios now and again and sometimes you can just handle the display logic in the controller before rendering and through Content Editor education. It would be useful if we could do this more easily with Custom Validators though.
    – Adam Seabridge
    yesterday


















  • Yeah, talking to another developer we already it seems have a custom validator that's doing something via the item:saving event, so I should be able to just tack this additional validation on to it. Thanks for helping me pinpoint the issue and solution.
    – Levi Wallach
    yesterday










  • No worries. I come across these kind of scenarios now and again and sometimes you can just handle the display logic in the controller before rendering and through Content Editor education. It would be useful if we could do this more easily with Custom Validators though.
    – Adam Seabridge
    yesterday
















Yeah, talking to another developer we already it seems have a custom validator that's doing something via the item:saving event, so I should be able to just tack this additional validation on to it. Thanks for helping me pinpoint the issue and solution.
– Levi Wallach
yesterday




Yeah, talking to another developer we already it seems have a custom validator that's doing something via the item:saving event, so I should be able to just tack this additional validation on to it. Thanks for helping me pinpoint the issue and solution.
– Levi Wallach
yesterday












No worries. I come across these kind of scenarios now and again and sometimes you can just handle the display logic in the controller before rendering and through Content Editor education. It would be useful if we could do this more easily with Custom Validators though.
– Adam Seabridge
yesterday




No worries. I come across these kind of scenarios now and again and sometimes you can just handle the display logic in the controller before rendering and through Content Editor education. It would be useful if we could do this more easily with Custom Validators though.
– Adam Seabridge
yesterday











3














I would recommend implementing a custom Item validation rule.




Note: This is different from a field validation, in that it validates the entire item instead of a single field.




1. Create custom validator



Create a new class that implements the Sitecore.Data.Validators.StandardValidator base class. In the Evaluate() method, get both fields and check to see if either of them has a value:



public class AtLeastOneFieldPopulatedValidator : StandardValidator
{
public override string Name => "At Least One Field Populated";

public AtLeastOneFieldPopulatedValidator() {}

public UrlCharacterValidator(SerializationInfo info, StreamingContext context) : base(info, context) {}

protected override ValidatorResult Evaluate()
{
Item item = base.GetItem();
if (item == null)
{
return ValidatorResult.Valid;
}
if (!string.IsNullOrEmpty(item["Field 1"]) || !string.IsNullOrEmpty(item["Field 2"]))
{
return ValidatorResult.Valid;
}
return base.GetFailedResult(ValidatorResult.CriticalError);
}

protected override ValidatorResult GetMaxValidatorResult()
{
return base.GetFailedResult(ValidatorResult.Error);
}
}


2. Create Validation Rule item



First, create a new Validation Rule (template /sitecore/templates/System/Validation/Validation Rule) item somewhere below this node:



/sitecore/system/Settings/Validation Rules/Item Rules



item validator tree




Important: Make sure you populate the Type field with your fully-qualified name of your custom validator's class (e.g. Custom.Services.AtLeastOneFieldPopulatedValidator, Custom.Services).




3. Associate your Validation Rule to your items



On the __Standard values of your item's template, show Standard Fields (View ribbon tab -> Standard fields) and add your Validation Rule to the appropriate validation fields. I recommend including it in all four.



(Optional) Extra credit: Add parameters



I've not tested this, but I'm sure there's a way to pass parameters using the Parameters field on the Validation Rule item. In these parameters, you could pass a list of the fields to check so your validator can be reused by creating multiple Validation Rule items in Sitecore.



parameters field






share|improve this answer























  • did you test this code? It would be great if it works but my understanding is that item["Field 2"] would not have a value at the point the validation for item["Field 1"] fires. This is mentioned in the SSE posts I've referenced in my answer.
    – Adam Seabridge
    yesterday










  • I believe this will be different, however, because this is an Item validator (not a field validator). I believe it still runs after every field is updated (I haven't dug through the CE JS to verify that), but it validates the entire item instead of just a single field.
    – Dan Sinclair
    yesterday










  • It also appears this is the same solution they used in the second SSE post you linked: "We additionally put an item validator on the component itself to prevent it from going through workflow."
    – Dan Sinclair
    yesterday










  • Ahr right, sorry yes it's not a field validator so the values should both be set. No worries then.
    – Adam Seabridge
    yesterday










  • @AdamSeabridge you point out a valid concern, though, that it was not clear. I've edited the answer to attempt to call that out more clearly.
    – Dan Sinclair
    yesterday
















3














I would recommend implementing a custom Item validation rule.




Note: This is different from a field validation, in that it validates the entire item instead of a single field.




1. Create custom validator



Create a new class that implements the Sitecore.Data.Validators.StandardValidator base class. In the Evaluate() method, get both fields and check to see if either of them has a value:



public class AtLeastOneFieldPopulatedValidator : StandardValidator
{
public override string Name => "At Least One Field Populated";

public AtLeastOneFieldPopulatedValidator() {}

public UrlCharacterValidator(SerializationInfo info, StreamingContext context) : base(info, context) {}

protected override ValidatorResult Evaluate()
{
Item item = base.GetItem();
if (item == null)
{
return ValidatorResult.Valid;
}
if (!string.IsNullOrEmpty(item["Field 1"]) || !string.IsNullOrEmpty(item["Field 2"]))
{
return ValidatorResult.Valid;
}
return base.GetFailedResult(ValidatorResult.CriticalError);
}

protected override ValidatorResult GetMaxValidatorResult()
{
return base.GetFailedResult(ValidatorResult.Error);
}
}


2. Create Validation Rule item



First, create a new Validation Rule (template /sitecore/templates/System/Validation/Validation Rule) item somewhere below this node:



/sitecore/system/Settings/Validation Rules/Item Rules



item validator tree




Important: Make sure you populate the Type field with your fully-qualified name of your custom validator's class (e.g. Custom.Services.AtLeastOneFieldPopulatedValidator, Custom.Services).




3. Associate your Validation Rule to your items



On the __Standard values of your item's template, show Standard Fields (View ribbon tab -> Standard fields) and add your Validation Rule to the appropriate validation fields. I recommend including it in all four.



(Optional) Extra credit: Add parameters



I've not tested this, but I'm sure there's a way to pass parameters using the Parameters field on the Validation Rule item. In these parameters, you could pass a list of the fields to check so your validator can be reused by creating multiple Validation Rule items in Sitecore.



parameters field






share|improve this answer























  • did you test this code? It would be great if it works but my understanding is that item["Field 2"] would not have a value at the point the validation for item["Field 1"] fires. This is mentioned in the SSE posts I've referenced in my answer.
    – Adam Seabridge
    yesterday










  • I believe this will be different, however, because this is an Item validator (not a field validator). I believe it still runs after every field is updated (I haven't dug through the CE JS to verify that), but it validates the entire item instead of just a single field.
    – Dan Sinclair
    yesterday










  • It also appears this is the same solution they used in the second SSE post you linked: "We additionally put an item validator on the component itself to prevent it from going through workflow."
    – Dan Sinclair
    yesterday










  • Ahr right, sorry yes it's not a field validator so the values should both be set. No worries then.
    – Adam Seabridge
    yesterday










  • @AdamSeabridge you point out a valid concern, though, that it was not clear. I've edited the answer to attempt to call that out more clearly.
    – Dan Sinclair
    yesterday














3












3








3






I would recommend implementing a custom Item validation rule.




Note: This is different from a field validation, in that it validates the entire item instead of a single field.




1. Create custom validator



Create a new class that implements the Sitecore.Data.Validators.StandardValidator base class. In the Evaluate() method, get both fields and check to see if either of them has a value:



public class AtLeastOneFieldPopulatedValidator : StandardValidator
{
public override string Name => "At Least One Field Populated";

public AtLeastOneFieldPopulatedValidator() {}

public UrlCharacterValidator(SerializationInfo info, StreamingContext context) : base(info, context) {}

protected override ValidatorResult Evaluate()
{
Item item = base.GetItem();
if (item == null)
{
return ValidatorResult.Valid;
}
if (!string.IsNullOrEmpty(item["Field 1"]) || !string.IsNullOrEmpty(item["Field 2"]))
{
return ValidatorResult.Valid;
}
return base.GetFailedResult(ValidatorResult.CriticalError);
}

protected override ValidatorResult GetMaxValidatorResult()
{
return base.GetFailedResult(ValidatorResult.Error);
}
}


2. Create Validation Rule item



First, create a new Validation Rule (template /sitecore/templates/System/Validation/Validation Rule) item somewhere below this node:



/sitecore/system/Settings/Validation Rules/Item Rules



item validator tree




Important: Make sure you populate the Type field with your fully-qualified name of your custom validator's class (e.g. Custom.Services.AtLeastOneFieldPopulatedValidator, Custom.Services).




3. Associate your Validation Rule to your items



On the __Standard values of your item's template, show Standard Fields (View ribbon tab -> Standard fields) and add your Validation Rule to the appropriate validation fields. I recommend including it in all four.



(Optional) Extra credit: Add parameters



I've not tested this, but I'm sure there's a way to pass parameters using the Parameters field on the Validation Rule item. In these parameters, you could pass a list of the fields to check so your validator can be reused by creating multiple Validation Rule items in Sitecore.



parameters field






share|improve this answer














I would recommend implementing a custom Item validation rule.




Note: This is different from a field validation, in that it validates the entire item instead of a single field.




1. Create custom validator



Create a new class that implements the Sitecore.Data.Validators.StandardValidator base class. In the Evaluate() method, get both fields and check to see if either of them has a value:



public class AtLeastOneFieldPopulatedValidator : StandardValidator
{
public override string Name => "At Least One Field Populated";

public AtLeastOneFieldPopulatedValidator() {}

public UrlCharacterValidator(SerializationInfo info, StreamingContext context) : base(info, context) {}

protected override ValidatorResult Evaluate()
{
Item item = base.GetItem();
if (item == null)
{
return ValidatorResult.Valid;
}
if (!string.IsNullOrEmpty(item["Field 1"]) || !string.IsNullOrEmpty(item["Field 2"]))
{
return ValidatorResult.Valid;
}
return base.GetFailedResult(ValidatorResult.CriticalError);
}

protected override ValidatorResult GetMaxValidatorResult()
{
return base.GetFailedResult(ValidatorResult.Error);
}
}


2. Create Validation Rule item



First, create a new Validation Rule (template /sitecore/templates/System/Validation/Validation Rule) item somewhere below this node:



/sitecore/system/Settings/Validation Rules/Item Rules



item validator tree




Important: Make sure you populate the Type field with your fully-qualified name of your custom validator's class (e.g. Custom.Services.AtLeastOneFieldPopulatedValidator, Custom.Services).




3. Associate your Validation Rule to your items



On the __Standard values of your item's template, show Standard Fields (View ribbon tab -> Standard fields) and add your Validation Rule to the appropriate validation fields. I recommend including it in all four.



(Optional) Extra credit: Add parameters



I've not tested this, but I'm sure there's a way to pass parameters using the Parameters field on the Validation Rule item. In these parameters, you could pass a list of the fields to check so your validator can be reused by creating multiple Validation Rule items in Sitecore.



parameters field







share|improve this answer














share|improve this answer



share|improve this answer








edited yesterday

























answered yesterday









Dan SinclairDan Sinclair

1,362525




1,362525












  • did you test this code? It would be great if it works but my understanding is that item["Field 2"] would not have a value at the point the validation for item["Field 1"] fires. This is mentioned in the SSE posts I've referenced in my answer.
    – Adam Seabridge
    yesterday










  • I believe this will be different, however, because this is an Item validator (not a field validator). I believe it still runs after every field is updated (I haven't dug through the CE JS to verify that), but it validates the entire item instead of just a single field.
    – Dan Sinclair
    yesterday










  • It also appears this is the same solution they used in the second SSE post you linked: "We additionally put an item validator on the component itself to prevent it from going through workflow."
    – Dan Sinclair
    yesterday










  • Ahr right, sorry yes it's not a field validator so the values should both be set. No worries then.
    – Adam Seabridge
    yesterday










  • @AdamSeabridge you point out a valid concern, though, that it was not clear. I've edited the answer to attempt to call that out more clearly.
    – Dan Sinclair
    yesterday


















  • did you test this code? It would be great if it works but my understanding is that item["Field 2"] would not have a value at the point the validation for item["Field 1"] fires. This is mentioned in the SSE posts I've referenced in my answer.
    – Adam Seabridge
    yesterday










  • I believe this will be different, however, because this is an Item validator (not a field validator). I believe it still runs after every field is updated (I haven't dug through the CE JS to verify that), but it validates the entire item instead of just a single field.
    – Dan Sinclair
    yesterday










  • It also appears this is the same solution they used in the second SSE post you linked: "We additionally put an item validator on the component itself to prevent it from going through workflow."
    – Dan Sinclair
    yesterday










  • Ahr right, sorry yes it's not a field validator so the values should both be set. No worries then.
    – Adam Seabridge
    yesterday










  • @AdamSeabridge you point out a valid concern, though, that it was not clear. I've edited the answer to attempt to call that out more clearly.
    – Dan Sinclair
    yesterday
















did you test this code? It would be great if it works but my understanding is that item["Field 2"] would not have a value at the point the validation for item["Field 1"] fires. This is mentioned in the SSE posts I've referenced in my answer.
– Adam Seabridge
yesterday




did you test this code? It would be great if it works but my understanding is that item["Field 2"] would not have a value at the point the validation for item["Field 1"] fires. This is mentioned in the SSE posts I've referenced in my answer.
– Adam Seabridge
yesterday












I believe this will be different, however, because this is an Item validator (not a field validator). I believe it still runs after every field is updated (I haven't dug through the CE JS to verify that), but it validates the entire item instead of just a single field.
– Dan Sinclair
yesterday




I believe this will be different, however, because this is an Item validator (not a field validator). I believe it still runs after every field is updated (I haven't dug through the CE JS to verify that), but it validates the entire item instead of just a single field.
– Dan Sinclair
yesterday












It also appears this is the same solution they used in the second SSE post you linked: "We additionally put an item validator on the component itself to prevent it from going through workflow."
– Dan Sinclair
yesterday




It also appears this is the same solution they used in the second SSE post you linked: "We additionally put an item validator on the component itself to prevent it from going through workflow."
– Dan Sinclair
yesterday












Ahr right, sorry yes it's not a field validator so the values should both be set. No worries then.
– Adam Seabridge
yesterday




Ahr right, sorry yes it's not a field validator so the values should both be set. No worries then.
– Adam Seabridge
yesterday












@AdamSeabridge you point out a valid concern, though, that it was not clear. I've edited the answer to attempt to call that out more clearly.
– Dan Sinclair
yesterday




@AdamSeabridge you point out a valid concern, though, that it was not clear. I've edited the answer to attempt to call that out more clearly.
– Dan Sinclair
yesterday


















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.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • 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%2f15890%2fmake-one-of-two-sitecore-content-fields-required%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

1300-talet

1300-talet

Display a custom attribute below product name in the front-end Magento 1.9.3.8