How to add a timestamp field using Composite C1? - c1-cms

How can I add ChangeDate field to a global datatype in data perspective? I can add CreateDate field easily but stuck at record modification time.
This is how I add CreateDate field:
Just add a new field and rename it as CreateDate, type is Date
In the advanced tab; remove widget and set default value as function Now.
Can I add another field which one keeps the modification date automatically, if any?

I think event tracking of data addition and updating gives you a solution to add modified date.
You can even remove this modified date field from Mark up. But this will be in DB.
The five events that can be tracked in composite c1 data types are
OnAfterAdd
OnAfterUpdate
OnDeleted
OnBeforeAdd
OnBeforeUpdate
More information on data addition on the following link.

From: burningice
There is a package for it here which you can use to enable ChangeHistory on dynamic types https://bitbucket.org/burningice/compositec1contrib/src/8f53d846304f4dea942b9169481ea3e53580804e/ChangeHistory/?at=default
For static types, just make sure to inherit the Composite.Core.Types.IChangeHistory interface.
Read the full discussion online.

Related

Need clarification to understand the Standard Field in Salesforce App

I was creating the Recruitment App with Salesforce by going through the study material. I have a question. In the custom object, I saw that I have created a Standard field named "Position Title" and after that I have to create all other fields as "Custom Field & RelationShips". My question is -> Is it the case that Position title is the primary key/unique identified in this object? If that is the case, why the data type is Text(80)? I can have two records with same Position Title "Sr. Manager", right? In that case, my primary key/unique constraint violates.
I have attached the screenshot below:
I am new to salesforce. So please help me in understanding the system? Thanks in advance
Salesforce always create by default a group of fields called 'Standard fields', such as Created date, Last modified Date or Owner. In that list you'll probably interested in two, Id what is the primary key/unique identifier and Name which is a Text(80) field that you can't modify (only define if it's going to be text or an autonumber).
So to answer your first question, Name is actually not unique nor you identifier, and unfortunately at the moment salesforce doesn't give an easy option to have this functionality, in order to achieve that you could write a trigger with that restriction or define the Name as an autonumber and add the position title as a custom field with the unique checkbox marked.
The only problem with that last implementation is that the Name field is a special one with some behavior associated with it and it might obscure some of this functionality. For example, it will be the field shown when adding a relation to that object or in case you add the field to a related list, it will include a link to the actual object, but it will show the autonumber instead of the position title what doesn't give much information about the related object.
Here's a link with other people asking for the same idea.

Salesforce: Prevent autopopulating standard Name field

I have custom object on which there is a standard field 'Name'. The field type - text (Text(80)). It does not autopopulate, and the values ​​it can be set only through the edit page. This field is not mandatory on the project and on the edit page, but when I create a new record of this object this field is autopopulated by Id of this record. Although it is expected that the field should be left blank.
Can I fix this strange behavior with help of some options or settings? Are there any solutions?
I don't think so, it is either auto number or text in which case it'll be required, can not be left blank, salesforce autopopulates the record with the id in case you do not provide one and there is no setting to change that behavior (that i know of on current releases)
I'll recommend changing your requirements and at least populate the name of the record with something, a naming convention for the record on it's current stage would be helpful,
That way you can list all of your "ANONYMOUS" records and assign them into a queue so a business person can go and put the right info just to cite an example, a custom unique identifier which can be recognized by your system or an external application, but never blank

How would you model a table to record changes in other tables' records' values?

I am writing a model to record the changes that are made to other models so that there is a record of every attribute change. I'm looking for input on how best to structure the change record table.
For instance, I have a User model with a name attribute. I want to save a Change record to the database when that user has its name changed from Bob to Ted.
Furthermore, if a user updates multiple attributes on the User at the same time I would like to record these as being a single Change. For instance, a User changes both the name and email attributes from Bob and bob#bobsdomain.com to Ted and ted#teddy.com, respectively.
The set of attributes on a given object that are being changed are arbitrary. How would you structure the table?
Currently, I am doing something like the following (simplified):
Changes:
user_id:integer
changed_fields:string
old_values:text
new_values:text
In the above examples these records would look like the following:
:changed_fields => "name",
:old_values => "Bob",
:new_values => "Ted"
and
:changed_fields => "name,email",
:old_values => "Bob,bob#bobsdomain.com",
:new_values => "Ted,ted#teddy.com"
On the Change model I have special getter/setter methods that parse the input/output to map to specific formatting.
Is there a better way to model this kind of thing?
If not, what is the best way to format the values for the database to make parsing the input/output work best, given that the values can be arbitrary.
I am using Postgres as my DB and ActiveRecord as the ORM.
Storing both the old and new value is redundant. You could instead store just the new value at the time of the change, and make sure you also add a change record when a new row is created. If a row has been changed N times, it will have N+1 records in the change table, and you can find the differences between them retrospectively if you need to.
In fact, one approach is to have only one table containing all versions of the data. Instead of updating any rows in-place, make edits by inserting new rows. I've taken this approach while either using a boolean "latest" field, or using a foreign key from another table, to refer to the current version of each row.
These days though I'm using the django-reversion package to implement revision tracking for me. It uses a single table to record all versions of all tracked tables, storing a JSON representation of the state of each object at each version. It uses an additional table to track whole change-sets, so it can version changes that span multiple objects.
The solution that's best for you will depend on which operations you need to be able to do efficiently on your tables, and on what your ORM makes easy for you to work with. I hope this answer has been helpful at pointing out some approaches that have worked in other settings.

Trying to find name of TFS DB Table containing custom field data

I have a quick question, what is the name of the TFS 2010 database table that contains values for any custom fields.
I did a query against the TFS_Warehouse DB and the dbo.DimWorkItem table. However, I cannot find any of my custom work item fields under this table.
Can someone point me to the correct TFS 2010 table containing the custom field data? When I worked with Quality Center, the tables were pretty well defined so it was easy to do backend DB queries. TFS does not seem that intuitive.
Thanks
you have to add "reportable" to field definition.
Example - FIELD name="Scope" refname="xxx.Scope" type="String" reportable="dimension"
Wait few minutes and you'll see field in warehouse DB
look,
you need to go to your collection database, and to check a table called something like Fields.
there, you will find the new field properties and the type as well.
you can change the type to string and to be reportable.
go to the table of the WORKITEMLATEST, and check the field- you can see the name of the field like what was mentioned in the FIELDS table,.
open your work item normally, edit that field information, click save...
you can see your data updated in the WORKITEMLATEST table
BUT...
the problem is the STRING type is limited... I tried to add more text.. it keep telling me that number of character is over limit !

Database name convention: DATETIME column

What is your naming convention for DATETIME columns (in my case, using MS SQL Server)
For a column that stores when the row was created CreatedDatetime makes sense, or LastModifiedDatetime.
But for a simple table, let's say one called Event, would you create columns called:
TABLE Event
====================================================
EventID, // Primary key
EventDatetime, // When the event is happening
EventEnabled // Is the event is on
or these column names
TABLE Event
====================================================
ID, // Primary key
Datetime, // When the event is happening
Enabled // Is the event is on
If you'd use neither convention: Please provide the column name you would use.
I normally name DATETIME columns as ACTION_WORD_on: created_on, completed_on, etc.
The ACTION_WORD defines what the column represents, and the suffix (_on) indicates that the column represents time.
Other suffixes (or even prefixes) may be used to specify the data type (_at, _UTC, when_, etc).
Be descriptive. Be consistent.
Why call it EventDateTime, when you don't also use EventIDInt, or EventEnbaledVarchar? Why inlcude the data type in the column name? (My rule of thumb is, if they're accessing data in a table, they better know what the column data types are, 'cause otherwise they don't know what they're working with.)
These days I prefer what I think of as descriptive column names, such as:
CreateDate
DateCreated
CreatedAt
CreatedOn (if there's no time portion)
AddedOn (might be semanitcally more appropriate, depending on the data)
Picking a "label" and using it consistantly in every table that requires that kind data is also a good thing. For example, having a "CreateDate" column in (almost) every table is fine, because then you will always know which column in every table will tell you when a row was created. Don't get hung up with the "but they all have to have unique names" argument; if you're writing a query, you had better know which tables you're pulling each column from.
--Edit--
I just recalled an exception I've done in the past. If a DateTime (or SmallDateTime) column will contain no time portion, just the date, as a "reminder" I'd put "Date" in the column name, such as "BilledDate" instead of "Billed" or "BilledOn". This shouldn't apply when tracking when rows were added, since you'd want the time as well.
The name should communicate what Business meaning of the data is in the column... "DateTime" is just the Type of the data. Is it when the event happened? when it was recorded? when it was stored in the DB? When the data was last modified?
If it efficiently communicates the meaning of what the column contains, the name is fine. "DateTime" is not fine. "EventDateTime" is only very slightly better. If the table holds events, then any datetime field in the table is an EventDateTime (It records some datetime related to the event). Although if there's only one datetime column in an "Events" table, then EventDateTime implies that it's when the event happened, so that's probably ok.
Choose or select the name so it communicates the meaning of the value...
Given edited question, some suggested names might be:
Occurred, or OccurredDateTime, or OccurredUTC, (or OccurredLocal), or, if events in your business model have duration, then perhaps StartedUtc, or BeganUtc, or InitiatedUtc, etc.
I prefer to create columns in the second form--although I'd probably want a more descriptive name than Datetime, depending on what its use would be.
Edit: In this sort of situation, I might actually go with a hybrid for that single field, and make it 'EventDate', 'StartDate', or something similar.
Maybe that's just me, but I don't believe you should name your columns with data types, neither replicate the table name all over the fields.
I would avoid using datatypes for column names (a DATETIME column called Datetime), so I vote for the first option.
I'd call the column HappensAt, because the row describe an event and the attribute (column) in question details when it happens. As a general rule I try to name my tables with singular nouns and my attributes with phrases that can be used to read, like
tablename(key) columname columnvalue
So I would then be able to say
event(131) HappensAt Dec 21, 2009, 21:30
However this isn't an inviolable rule. I'd still record the date someone was born in a BirthDate column, not a WasBornOn column. You have to bear in mind the common usages of natural language when you name things. Strive for natural usage and the rest will follow. Follow rules blindly and your readers will struggle for comprehension.
there are many good answers here, so I won't duplicate. But remember don't ever name a column a reserved word!!!
also, I really like the column names in option 1.
I would likely use something like "WhenRaisedUtc".

Resources