How can I set such validations

1. The "Date To" of an event should come after the "Date From"

2. The date should not be in the past

3. The amount should not be less than 0

 

Like 1

Like

4 comments

Hello Arkadiusz Polus, in order to perform this kind of validation you need to write a little bit of code in the schema page. Perhaps this article of the academy will light things up for you. 

https://academy.creatio.com/docs/developer/getting_started/develop_appl…

what about business rules? 

Arkadiusz Polus,

Business rules do not permit these operators >, >=, <, <=, so it would not be possible to solve these three cases that you mentioned earlier.

 

Maybe something that should be included in business rules in the future ? ?

Show all comments

Has anyone been successful using the CreatioSDK in sending date updates via either InsertQuery or UpdateQuery?

 

I've tried sending dates in all the following formats but all result in an error:

 

yyyy-MM-dd

yyyy-MM-ddTHH:mm:ss

yyyy-MM-ddTHH:mm:ss.fff 

yyyy-MM-ddTHH:mm:ss.fffffffZ

M/d/yyyy

d/M/yyyy

dd/MM/yyyy

 

The dates I'm trying to send are defined as DataValueType.Date and I've tried specifying that in the Update/InsertQuery and in desperation also tried specifying as DataValueType.DateTime. 

 

If I omit dates from the Insert/Update queries the updates are successful. 

 

I can successfully enter dates in the records I'm trying to update via the Creatio UI.

 

Here's an example of a stripped down InsertQuery request, including the DueDate column causes an error 500, if excluded the insert is successful:

 

{

  "QueryId": null,

  "QueryKind": 0,

  "ColumnValues": {

    "Items": {

      "Title": {

        "ExpressionType": 2,

        "IsBlock": false,

        "ColumnPath": null,

        "Parameter": {

          "DataValueType": 1,

          "Value": "Test SDK Three",

          "ArrayValue": null,

          "ShouldSkipConvertion": false

        },

        "FunctionType": 0,

        "MacrosType": 0,

        "FunctionArgument": null,

        "FunctionArguments": null,

        "DateDiffInterval": 0,

        "DatePartType": 0,

        "AggregationType": 0,

        "AggregationEvalType": 0,

        "SubFilters": null,

        "ArithmeticOperation": 0,

        "LeftArithmeticOperand": null,

        "RightArithmeticOperand": null

      },

      "Contact": {

        "ExpressionType": 2,

        "IsBlock": false,

        "ColumnPath": null,

        "Parameter": {

          "DataValueType": 0,

          "Value": "fede06a3-1270-4464-8049-c7afb144a018",

          "ArrayValue": null,

          "ShouldSkipConvertion": false

        },

        "FunctionType": 0,

        "MacrosType": 0,

        "FunctionArgument": null,

        "FunctionArguments": null,

        "DateDiffInterval": 0,

        "DatePartType": 0,

        "AggregationType": 0,

        "AggregationEvalType": 0,

        "SubFilters": null,

        "ArithmeticOperation": 0,

        "LeftArithmeticOperand": null,

        "RightArithmeticOperand": null

      },

      "DueDate": {

        "ExpressionType": 2,

        "IsBlock": false,

        "ColumnPath": null,

        "Parameter": {

          "DataValueType": 8,

          "Value": "2022-05-28",

          "ArrayValue": null,

          "ShouldSkipConvertion": false

        },

        "FunctionType": 0,

        "MacrosType": 0,

        "FunctionArgument": null,

        "FunctionArguments": null,

        "DateDiffInterval": 0,

        "DatePartType": 0,

        "AggregationType": 0,

        "AggregationEvalType": 0,

        "SubFilters": null,

        "ArithmeticOperation": 0,

        "LeftArithmeticOperand": null,

        "RightArithmeticOperand": null

      },

      "Amount": {

        "ExpressionType": 2,

        "IsBlock": false,

        "ColumnPath": null,

        "Parameter": {

          "DataValueType": 5,

          "Value": 6718.35,

          "ArrayValue": null,

          "ShouldSkipConvertion": false

        },

        "FunctionType": 0,

        "MacrosType": 0,

        "FunctionArgument": null,

        "FunctionArguments": null,

        "DateDiffInterval": 0,

        "DatePartType": 0,

        "AggregationType": 0,

        "AggregationEvalType": 0,

        "SubFilters": null,

        "ArithmeticOperation": 0,

        "LeftArithmeticOperand": null,

        "RightArithmeticOperand": null

      },

      "Budget": {

        "ExpressionType": 2,

        "IsBlock": false,

        "ColumnPath": null,

        "Parameter": {

          "DataValueType": 5,

          "Value": 0.0,

          "ArrayValue": null,

          "ShouldSkipConvertion": false

        },

        "FunctionType": 0,

        "MacrosType": 0,

        "FunctionArgument": null,

        "FunctionArguments": null,

        "DateDiffInterval": 0,

        "DatePartType": 0,

        "AggregationType": 0,

        "AggregationEvalType": 0,

        "SubFilters": null,

        "ArithmeticOperation": 0,

        "LeftArithmeticOperand": null,

        "RightArithmeticOperand": null

      }

    }

  },

  "RootSchemaName": "Opportunity",

  "IncludeProcessExecutionData": false

}

 

  

Like 0

Like

1 comments
Best reply

Hello Jerry, 



Please try to pass Date into Creatio with the following format in UTC time:

 

      "dataValueType":8,
      "value":"\"2000-01-01T00:00:00.000\""

Kind regards,
Roman

Hello Jerry, 



Please try to pass Date into Creatio with the following format in UTC time:

 

      "dataValueType":8,
      "value":"\"2000-01-01T00:00:00.000\""

Kind regards,
Roman
Show all comments

Hello everybody

When we request section data via OData the date fields are returned with the authenticated user time-zone setting and not UTC.

Is there a way to obtain date fields in UTC via OData, regardless authenticated user time-zone?

Thanks

Like 0

Like

1 comments

Hello,

 

The only way to achieve your business task is to create a separate user that will be used in OData requests authentication, set the timezone for this user as UTC, make this user a system administrator and execute OData requests under this user.

 

Best regards,

Oscar

Show all comments

Dear mates,

How can i format date in Creation source code ?

When i do this:

var esq = this.Ext.create("Terrasoft.EntitySchemaQuery", {
   rootSchemaName: "Order"
});
 
esq.addColumn("Date");
 
esq.getEntityCollection( function(result) {
    result.collection.each ( function (order) {
       this.console.log(Date);
    });
});

the system return me:

function Date() { [native code] }

What the way to format Date ?

Thanks,

Nicolas

 

Like 0

Like

2 comments

The Date can be formatted via default js functions. Please feel free to find out more about working with Date in JavaScript in the article by the link below:

https://css-tricks.com/everything-you-need-to-know-about-date-in-javascript/

Also there are some examples of working with Date in ESQ in the article on academy :

https://academy.creatio.com/documents/technic-sdk/7-15/entityschemaquery-class-filters-handling

 

You can format the date based on the current users culture settings using the following:

var formattedDateString = myDate.toLocaleDateString(Terrasoft.currentUserCultureName);

Ryan

Show all comments



Dear mates,

I'd like to set a date to null in a process. I tryed several ways but it never worked.

Is it possible to do this in a process or should i do it in JS ?

Thanks,

Nicolas

Like 0

Like

3 comments

Well i did it in js:

            onEntityInitialized: function() {

               

                this.callParent(arguments);

                

                if (this.get("Stage").value === "991d70f4-7a10-42b8-bb9c-fd8096d05d9b") {

                    this.showInformationDialog("Set the new Date to call");

                    this.set("DateToCall", null);

                }

            }

If someone knows how to set a Date to Null in a process, i m interested with

LÉZORAY Nicolas,

You can create date parameter and leave it empty. Then specify this parameter as a value that must be inserted to date field. It will leave this field empty or make it empty if it was filled in.

Best regards,

Angela

Thank you it works !

Show all comments

Hello

I know that Bpmonline supports Gregorian Calendar, what about supporting other calenders like (Hijri Calendar)

Regards

Like 0

Like

1 comments

Hello,

Unfortunately, by default there are no any other calendars or Hijri Calendar time format. If you need to set up the new calendar, for example for case resolution time calculation, feel free to refer to the following article and create your custom calendar (calendar setup paragraph) https://academy.bpmonline.com/documents/service-enterprise/7-15/how-setup-response-and-resolution-time-calculation

Other than that, unfortunately, it is not possible to set up the time and date format according to Hijri calendar. We will register the idea of adding more calendars in our R&D team backlog for implementation in the future application releases. 

Best regards,

Dean

Show all comments

Hi,

I am trying to build a process that will subtract 2 dates and record the difference in an integer field for all the records in the CRM. But for some reason, I can not get the result as required.

 

 

Like 0

Like

14 comments

Hello, 

Formula value uses standard C# syntax. In your case subtraction of 2 datetime fields gives you a TimeSpan, you can get the number of days in the TimeSpan by using Days property (TotalHours if you want to calculate difference in hours). 

So to get the difference between 2 date fields you can do the following formula: 

([#Date 1#] - [#Date 2#]).Days

You can assign this value to a business process parameter and them with modify data update the needed field with this parameter. 

Best regards,

Dennis

Dennis Hudson,

 Thanks for the reply. I am trying to build a business process to run every morning and that process should read the two dates and update field with the difference in those dates in days.

Can you guide with how to build such a process?

Currently it's as below and is really working. Just can't figure out how to read all the records and then update the field based on the current values of the record.

 

aaykay,

There are 2 options how you can do that: 

1) You can add a boolean column to your object (Something like Processed) and loop through all records, which have processed = false. After that you can read the first record in the selection with the mentioned filter, process date columns and after that set the Processed to true. You would need to loop until there is a record that has processed = false (count > 0). 

After all the mentioned operations you would need to set Processed of all records to false (one Modify data element). 

2) You can read all records as a collection, pass it to script task and operate with them in a script task. Here is some documentation on using collection: 

 https://community.bpmonline.com/questions/use-collection-parameter-script-task

https://community.bpmonline.com/questions/use-script-task-update-column-read-data-result-collection

Best regards, 

Dennis 

Dennis Hudson writes:

You can add a boolean column to your object (Something like Processed) and loop through all records, which have processed = false.

 

How do I loop through the records in the business process?

aaykay,

It should look similar to the screenshot below:

http://prntscr.com/nr79cf

Best regards,

Dennis

Dennis Hudson,

 When I run the process and put a constant number such as 07 or 50 or any other value, the business process updates the value in the specified field. But when I try to compute the value using the dates, it doesn't work. I am using the same formula as you mentioned earlier in the first comment (date2 - date1).Days.

Can you tell what might be going wrong?

aaykay,

Could you please specify what do you mean by 'doesn't work'? It gives you an error or the value is incorrect? In first case please give me an error message, in the second case - what dates do you input and value do you get when using the formula? Also, could you please send a screenshot of your formula and a part of process flow in which you use it? 

Dennis Hudson,

 Here are the screenshots:

1. Complete Process

2. Date formula for filled

 

3. Date formula if closed:

 

4. Final modification:

 

I am neither getting an error nor any other response. The integer field that I am trying to update shows value = 0, which I guess is the default value of field of type integer. 

Dennis Hudson,

 I omitted conditional flow and now I am getting the following output when I run the process for only status = Closed

The variable "DateDifference" now has value = -737,065

aaykay,

It happens because one of the date values is empty, if you fill in both date/time fields you should get a correct result. 

aaykay writes:

The variable "DateDifference" now has value = -737,065

Dennis Hudson,

Both the fields are filled. Please find the screenshot below.

aaykay,

Probably you are calculating those fields using the dates of one particular record that has one of the dates not filled in, and not for each record separately. Please write to the support@bpmonline.com for more detailed analysis. I've double checked the formula itself and it works fine, probably the issue is in the process flow.

Best regards,

Dennis  

Dennis Hudson,

 You can find the business process in the screenshots above. Even I think something is not upto the mark with process but only if I knew.

aaykay,

It's hard to determine what's wrong here from screenshots. I think it will be better to contact support. 

Show all comments

Hi,

Have two date fields for which I need to calculate the difference in days, i.e. UsrEndDate- UsrStartDate = UsrDayDifference

I have implemented the following code so far:

 

define("AccountPageV2", [], function() {

return {

entitySchemaName: "Account",

details: /**SCHEMA_DETAILS*/{}/**SCHEMA_DETAILS*/,

attributes: {

        "UsrDayDifference": {

               dataValueType: Terrasoft.DataValueType.FLOAT,

               dependencies: [

                   {

                       columns: ["UsrStartDate", "UsrEndDate"],

                       methodName: "calculateDays"

                   }

               ]

           }

},

 

 methods: {

            onEntityInitialized: function() {

                this.callParent(arguments);

                this.calculateDays();

            },

            calculateDays: function() {

                var result = (this.get("UsrEndDate") - this.get("UsrStartDate")).TotalDays;

                this.set("UsrDayDifference", result);

            }

        },

diff: /**SCHEMA_DIFF*/[

{

............

 

 

Can someone please explain what I'm doing wrong here?

 

 

Thank you,

 

Eduan

Like 0

Like

1 comments

p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Helvetica Neue'; color: #454545}
span.Apple-tab-span {white-space:pre}

You can use this function: 

 

        numberOfDays: function(date1, date2) {

                if (date1 instanceof Date && date2 instanceof Date) {

                    var oneDay = 24 * 60 * 60 * 1000; // hours*minutes*seconds*milliseconds

                    var diffDays = Math.round(Math.abs((date1.getTime() - date2.getTime()) / oneDay));

                    return diffDays;

                }

                else {

                    return 0;

                }

            },

 

 

I hope it works for you.

Show all comments