I am using sitecore 8.2.
I need to add two fields of attachment type in one template. But when I attach file in one field, same value is getting copied in another field of attachment type. How can I fix this?
The attachment field must be named "Blob" and if that still holds true, you can can only have 1 attachment field per template. If you have multiple then they will all need to be named "Blob" and therefore will all be hydrated with the same value.
I found the name restriction in this article about the field in Siteocre 6.6
http://blogs.perficient.com/digitaltransformation/2012/12/05/working-with-the-sitecore-attachment-field-type/
Related
In dotCMS,
1) I Created a content type with name product with 3 fields (name, id, description). Name and id fields created by selecting unique option. Name and Id fields combination should give uniqueness. But in dotCMS there is individual field unique option. When I try to add new content with below data it is failing to insert .
a) name: prod1, id : 1, description: phone.
b) name: prod2, id: 1, description: tablet.
2) While calling REST api to save/publish a content, is there any way to pass multiple input instead of single PUT or POST. https://dotcms.com/docs/latest/rest-api-end-points#ContentResource
Is there any solution for above two problems?
The Unique option applies only to a single field, and ensures each content item has a Unique value for that field only. There's no built-in way to check for uniqueness on multiple fields.
However one relatively simple way to do what you want is to create a separate custom field that automatically fills with the value of the name and ID fields (just append the value of the two fields), and then just set the Unique flag on the custom field. For more information on custom fields, see https://auth.dotcms.com/docs/latest/custom-field. Note that the dotCMS starter site includes many custom fields you can use as examples as well.
I'm not sure what you mean. If you mean can you make a single REST call to create or update multiple individual content items, then the answer is no - you need to do a separate REST call for each item you want to create or update. (So you'd either need to code a loop to create each piece of content, or use another method such as importing content using a CSV file).
If that's not what you mean, can you please clarify your question?
I have a boolean atrribute whose default is false. How can i get the date when the attribute was changed to true?
The is_changed gives you if the value was changed. I want the date when the attribute was first changed.
How do i get it in rails?
add attribute 'first_change' in that table which will save time stamp of every first change of the boolean attribute changed to true or false, then in model write the callback like this
before_update :check_changes
def check_changes
if self.<boolean_attribute>.is_changed? and first_change.nil?
self.update(first_change: Time.now)
end
end
After this you can check when the boolean attribute was changed.
You can wrap your boolean attribute in distinct model and from there you can easily trace when specific field was initially setted up or updated. In your current model you can't trace changing state of specific attributes, only the whole object, but it's not what you need I guess.
Well, looks like you basically want the feature of git in ActiveRecord records.
There are two ways
Use a separate col like changed_date. Update it whenever the field is changed for the first time.
I recommend this if your requirement is that simple. Do not use heavier gems.
Use libraries like VestalVersion or PaperTrail
these are helpful to track every activity in your records.
you can keep track of every changes, what its changed to and when
also you can revert your record to any point of time it was changed
I think there are two ways like above answer suggested to make a separate field and add date there when field changed first time or
you can use Public Activity gem that will log all the model activity with params.
It creates a activities table based on this table you can get the date of the fields when it was first changed but it is a lengthy process
I want to transfer content of items that belong to one template into another template.
For example, I have 5 fields in first template:
Tags
Image
Download link
Title
Date
and 5 fields in another template:
Type
Picture
Download Text
Title
Date
Here first two fields are different in the both the templates and remaining 3 fields are same.
So I want to migrate content of items that belong to first template to the second template. Also, I would like to highlight second template is a newly created template and currently no item from that template is created. So ultimately I am modifying the template of 100 items.
I tried overriding change template method of sitecore TemplateManager.ChangeTemplate(Item item, TemplateChangeList changes) but it empties the fields rather I want to retain the field data.
If anyone has any idea about this, please help.
I don't think there wouldn't be much difficulty to migrate all contents by changing the template. But, the main issue is that there are a number of page items which have to be changed to another template.
If you do, you can use PowerShellExtension. It takes only 1 second.
You can get the script idea from Sitecore Workflow Is Not Working
A solution is to inhertitance this fields, (using the "Base template" Field).
A other solution is to create your own change template command.
You can found here sample code: http://sitecore.stockpick.nl/nederlands/dialoge-box-in-een-command/ (it is a dutch article)
In code use: item.ChangeTemplate(template); and fill in the new field with the already stored values from the old template.
Whenever I create a new activity, I need a date field to be autopopulated ( it will be autopopulated but greyed out until and unless a checkbox next to it needs to be checked).
I perform a validation based on the date field, when a new activity is created. since the date field check box is not checked, it is not considering the value for the validation.
Any help or suggestion is appreciated.
Thanks.
Jaya Vignesh.
make use of predefault and postdefault values to populate current-date.
set field Read-only (BC field user property). You can find it under Business Component in object explorer.
Field read-only allows you to make a field read-only based on value of other field from same BC or joined field.
I perform a validation based on the date field, when a new activity is created. since the date field check box is not checked, it is not considering the value for the validation.
This requirement of yours isn't clear what exactly you want to validate. Since you are populating it bydefault, I don't find the significance in validating your own auto-populated data. well yet I provide a suggestion below
There are two types of validations, 1. Using configuration or 2. Using scripting. I am not pretty much sure if it can be achieved with configuration but scripting it is possible by overriding BusComp_presetFieldValue, BusComp_preWriteValue. The first one executed when you populate a field. And the latter one when you commit the record.
I have answer assuming your requirement. Let me know if you have any questions or clarifications required.
You can add the Predefault property of the field to be the following
System: TimeStamp
I have a timestamp field in a table and when i create a new instance of my object, set some fields, do not set the timestamp field and use the .Save(), i get an error saying that i cannot set an exlicite value to a timestamp field during an INSERT.
How can i have SubSonic not save anything in that perticular field?
Thank you
I'm not sure I perfectly understand the question, but the default SubSonic templates are set up to treat certain date/time fields as special cases, those being CreatedOn and ModifiedOn. You could look through your T4 template for references to those fields and modify their behavior.
Does this even apply to your situation, or are your timestamp fields named something else completely?
this is what you are looking for
http://mvcframeworkblog.blogspot.com/2009/10/subsonic-how-to-add-new-datatype.html