Question

I'm trying to update a column of type date using Entity object as below:

//Example 1
entity.SetColumnValue("BirthDate", "2001-09-15");
 
//Example 2
DateTime Date = DateTime.Parse("2001-09-15");
entity.SetColumnValue("BirthDate", Date );

The second example modifies the value successfully but when I open in client side the value doesn't show.

 

Like 0

Like

1 comments

Which error message do you get in the console from the client-side when opening a record? Also which value is being stored in the database. Finally, what does this.get("BirthDate") returns inside the onEntityInitialized method execution from the client-side?

 

Best regards,

Oscar

Show all comments

Hi Team,

I would like to prevent selecting the future date in the date field.
Kindly help me with any insight on this.

Note: All the future date should be greyed out and is not able to select (if it is clicked it shouldn't be selected or populated in the date field).

 

 

 

Thanks in Advance!

Regards,

Bhoobalan P.

Like 0

Like

3 comments

Hi Bhoobalan,

 

Please use the column validator instead that will do the same task:

setValidationConfig: function() {
              this.callParent(arguments);
              this.addColumnValidator("UsrDatetime1",this.dateTimeColumnValidator);
            },
          	dateTimeColumnValidator: function(){
              console.log(this.get("UsrDatetime1"));
              var invalidMessage = "";
              console.log(this.getSysDefaultValue(Terrasoft.SystemValueType.CURRENT_DATE_TIME));
              if (this.get("UsrDatetime1")>this.getSysDefaultValue(Terrasoft.SystemValueType.CURRENT_DATE_TIME)){
               	invalidMessage = this.get("Resources.Strings.ErrorMessage");
              } 
                return {
                  invalidMessage: invalidMessage
                };
              },

Just replace the UsrDatetime1 column with your date\rime column name and also create a localizable string with the "ErrorMessage" code.

 

Best regards,

Oscar

Oscar Dylan,

Thanks much for the precious response!

But still we could select the future date value, And after validation we throw a error message below the corresponding field name. 

We need to block selecting the future date, which could be possibly achieved via Jquery as below,

$("#dateField").datepicker({
    maxDate: 0
});

How could we achieve the same in our CREATIO Date field ?

Regards,

Bhoobalan P.

Bhoobalan Palanivelu,

 

This validator will also return a validation message upon saving a record with an incorrect date, so it's not possible to select the date\time grater than the current date\time:

And this is much easier than creating a custom logic for the date selector modal window so please use this approach.

 

Best regards,

Oscar

Show all comments

I have a business process that reads a collection of data.

Two of the fields that are being read are datetime fields.

Because the read data process reads many rows, I'm reading those rows in a script task and using the following code:

 

var ProductLines = Get<ICompositeObjectList<ICompositeObject>>("ReadDataUserTask1.ResultCompositeObjectList");

    foreach(var ProductLine in ProductLines) {

 

It's very important to understand that inside the foreach loop I'M NOT TRYING TO GET THE DATETIME FIELDS, BUT OTHER STRING TYPE FIELDS.

 

Once I run the process I get the following error message:

Terrasoft.Common.UnsupportedTypeException: Type "System.TimeSpan, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" is not supported.
   at Terrasoft.Common.CompositeObject.Add(String key, Object value)
   at Terrasoft.Common.CompositeObjectListUtilities.Transform(ICompositeObject source, IReadOnlyDictionary`2 keyMap)
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at System.Collections.Generic.List`1.InsertRange(Int32 index, IEnumerable`1 collection)
   at Terrasoft.Common.CompositeObjectListUtilities.Transform[T](IEnumerable`1 source, IReadOnlyDictionary`2 keyMap)
   at Terrasoft.Core.Process.Configuration.ReadDataUserTask.FillResultCompositeObjectList(IProcessParametersMetaInfo schemaElement, EntityCollection entityCollection)
   at Terrasoft.Core.Process.Configuration.ReadDataUserTask.InternalExecute(ProcessExecutingContext context)
   at Terrasoft.Core.Process.ProcessActivity.ExecuteElement(ProcessExecutingContext context)
   at Terrasoft.Core.Process.ProcessActivity.ExecuteItem(ProcessExecutingContext context)
   at Terrasoft.Core.Process.ProcessFlowElement.Execute(ProcessExecutingContext context)

 

I'm looking forward to having your assistance with the issue.

 

Best Regards,

Raz

Like 0

Like

1 comments

Hi Raz, 

 

Could you please provide a full script-task code you use so we will be able to test it at our end?

 

Regards,

Anastasiia

Show all comments

I only have one option to add a date to my section. 

 

The problem is that it shows the date AND the time-

 

I just need the DATE.

 

How do I get just the Date?

 

Thanks for your help!

Heather

 

 

Like 0

Like

2 comments

Hello Heather,

 

Please go to configurations and find the object that represents the section where the date\time field was added. Open this object and find your date\field column there, click on it and select displaying all column properties:

Once done please change the data type to "Date":

and save and publish the object once it is done. As a result you will see only dates in this column.

 

Best regards,

Oscar

Thank You!!!!!

Show all comments

Hi all,

       I try to set current date when click button by function

       var today = new Date();
       this.set("UsrSentAt", { value: today });

       But system shows error "The entered value does not match the column type" and can't display value on datetime picker. How can I set value for it?

Thanks

Like 0

Like

3 comments

Hello Toan!

Please double check if the "UsrSentAt" attribute has DATE type. 
Also, you should pass the value as it is, not creating the object.
this.set("UsrSentAt",   today );

For example:
I have created attribute 
"Date": {
                dataValueType: Terrasoft.DataValueType.DATE,
                type: Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN
              }

And I was able to successfully set it :
onEntityInitialized: function(){
                this.callParent(arguments);
                debugger;
                var date  = new Date();
                this.set("Date", date);
            }

Hi Alex,

Thanks for replying, see my screenshoot

Toan Mai,

Anyway, example that I sent above should work. Just pass the raw value in the set function instead of new object. 

this.set("UsrSentAt",   today );

Show all comments