How to add insert option Programmatically in C# Sitecore - sitecore

Insert option is not coming, can anyone help on this how I can programmatically insert option with item when we do not have insert option in _standardValue of template

When you create/edit the item from code, you can at the same time write to the Insert Options field, aka __Masters as field name, aka Branches as code constant, just as any other field. The field contains a pipe-separated list of template ID's. For example, like this:
item[Sitecore.FieldIDs.Branches] = "{TemplateId1}|{TemplateId2}|{...}";
// above is equivalent to item["__Masters"] = "...";
As you say, this will write a local value on the item being edited, and will therefore break any inheritance of the insert options that may be defined in __Standard Values. But in some scenarios this is actually better than having it on __Standard Values.

Related

Oracle APEX - make a field conditionally required

I have an item that is displayed conditionally - based on another item selection. I want to make that item non-required when hidden. What is the best way to do that?
As you have probably found, you cannot just set the dependent item's Required attribute, as this makes it required even when hidden. Instead you can create a Validation of type "Item is NOT NULL" on the dependent item, but with a server-side condition based on the value of the other item.
For example, suppose the first item is P12_JOB and the second is P12_COMMISSION, and P12_COMMISSION is only shown when P12_JOB = 'SALESMAN'. Then this Validation will do it:
As you can see there are various settings available there that you should check are appropriate for you e.g. Always Execute, Display Location.

QuickSight: How can I use ifelse() or any other alternative for multiple conditions according to input provided in the added parameter?

I get the option of ifelse() in the Functions list when I am trying to add a calculated field while editing the data, but do not get it from the 'Add' option where I get the option to Add title, Add description, Add calculated field, Add parameter. I get options like sumif, avgif, countif but there I can provide only one condition.
I want to create an ifelse(0) function with multiple conditions dependent on a parameter value which user selects from a dropdown.
If you want to add ifelse() function you have to add it at the Dataset section. it is not available in Data analysis section.
If you want to add multiple choice values in the parameter, then you have to add the list of items by
click on Add Parameter
in the "Create new parameter" dialogue box, select multiple values then write the list of items by each line in the below text area.
then click on the create.
Currently IfEsle() is not supported in analysis based on SPICE dataset. If you want to use IfElse() in analysis convert SPICE dataset to a Direct Query dataset.

How to use Droplist types in Sitecore template fields

Is there anyone who knows how to use "Droplist" type in template fields?
I guess "Droplist" is the same as <select><option></option></select> type.
I'd like to specify select list types with static values so that Sitecore editors can select only one of many available lists when they create a page.
My plan is to add CSS class names (<option>) in the list (<select>) and editors will use one of styles by selecting one of them.
How to add the values in select list? Do I have to write code?
The Droplist is similar to the Droplink field type in that they are both dropdowns. The Droplist will only store the name of the item (so it will not have a link to that item), while the Droplink stores the ID of the item. That means if you rename an option, or move it elsewhere in your Content Tree, the Droplist will not update (resulting in possible broken links), the Droplink will update.
You can add values to the Droplist by setting the Datasource field in the templates to something (for instance /sitecore/content/Home/CSS/ if that's where you would like to store your CSS class names).
You can access the Droplist in code like so:
Item item = Sitecore.Context.Item;
string css = item["FieldName"]; // Also possible is item.Fields["Fieldname"].Value;
A Droplink could be accessed like this:
string dropDownItemId = item["Fieldname"]; // Or, again, item.Fields["Fieldname"].Value; if you prefer
var cssItem = Sitecore.Context.Database.GetItem(dropDownItemId); // And now you can
// access any fields in this item.
Edit
A good article going into some more detail in the differences between Droplink and Droplist
I would proceed exactly as #Trayek suggested in his solution. To expand on that, this should be your implementation:
You create your own template, maybe called CSS Class, and you will add a Single-Line Text field to it, maybe called Value. You will put the actual CSS classes in that field when you create the items.
Next, you will add a folder item somewhere in the Content tree, and you will add your CSS Class items to that folder. That folder will also be the datasource of your droplist/droplink.
To set your datasource, this blog post should be of help. You will be looking to use number 1 under For Fields without Search (screenshot included, below). I wrote the article a while back, so if you need any additional help just let me know.

Sitecore adding field labels to name value list

I am trying to display field titles above the appropriate columns in a name value list in Sitecore.
e.g. So instead of this
The name value list would look like this
Is there an easy method of achieving this apart from writing a custom control?
There is no out of the box support for applying a label to the values in a name value list, as #jammykam mentioned.
Since what you are storing would not typically be handled as key/value data, the name value list type might not be the best fit for what you are doing - think what you would have to do if you needed to add extra information e.g. title. I would suggest creating a simple template for 'person details' and then add 'people' items as sub-items of your existing item.
Seems like you want to give the authors a hint regarding the input fields and the best way to do that is using the "Short Description" field in "Help" section of the template under Standard Values. You can possibly enter something like as a hint.
A less optimal option would be to set up standard values for that field so the authors always have a value that suggests the type of input value for key and value.

Sitecore values -- Template > Standard Values > Branch > Item

OK, here's the process I took...
create a new template "Mail Message"
create a "__Standard Values" item for the template
edit the "Subject" field in the standard values item: "Monthly email newsletter"
create a branch for the template
do NOT set the Subject field in the branch item
create an item from the branch
I would expect the subject would be the one from the standard values item, however it seems the branch field value is blank, and in turn the created item also has a blank subject field.
Should the Branch field value be that of the standard value. Or does the very act of creating a branch item eliminate any standard values you set.
Does the field versioing have any effect (e.g. Shared, Unversioned)?
I haven't been a big user of Branches, so I am surprised at the behaviour, but if it is normal, all good. Just want to confirm.
Alternatively, if the template or standard values were locked when the branch or item was created, the standard values might not have carried through.
Either way, you need to reset the value of the sitecore item. On the item, click the 'Reset' button, which is under the Versions tab and check the checkbox next to 'Subject'. Now, the field will show as 'Subject [standard value]'.
Hope that helps!
Creating the branch for the item template should copy the standard values and allow you to update the default values from the template.
So for example if you had "Monthly email newsletter" in the "Subject" field of the template it would be the same in the branch and all items created from that item.
Changing that field in the Standard Values should then update it in the branches and items.
If you have changed the field on the item however the link would be broken and you would no longer manage it from the standard values with out resetting the values.
Not sure on the shared/unversioned factor but dont think it effects the standard values.
When you change the value in branch template, you've broken the link already. So after that if you change the standard value, the value in branch template will not effect