Hello,
Is there possibility to add filter to compare part of date with some value ?
Have a look what i mean:
var esq = Ext.create("Terrasoft.EntitySchemaQuery", { rootSchemaName: "Opportunity" });
esq.filters.add("PC", Terrasoft.createColumnFilterWithParameter(
Terrasoft.ComparisonType.EQUAL, YEAR("CreationOn"),this.get("Year"))
Regards,
Like
Hello Marcin,
Here is a simple check I've used to extract the year of the CreatedOn column value for the account record when the account edit page is opened (added to the AccountPageV2 schema from "Custom" package):
onEntityInitialized: function (){ this.callParent(arguments); this.console.log("This is the value of year of CreatedOn: "+ this.get("CreatedOn").getFullYear()); if (this.get("CreatedOn").getFullYear()===2021){ this.console.log("The record was created in 2021"); } else { this.console.log("The record was created not in 2021"); } },
And it works perfectly on my end, the getFullYear() method does what it should so you can add it to your check:
var esq = Ext.create("Terrasoft.EntitySchemaQuery", { rootSchemaName: "Opportunity" }); esq.filters.add("PC", Terrasoft.createColumnFilterWithParameter( Terrasoft.ComparisonType.EQUAL,this.get("CreatedOn").getFullYear(),this.get("Year"))
In case "Year" is an actual column on the Opportunity edit page in our case.
Best regards,
Oscar
Hello Marcin,
Here is a simple check I've used to extract the year of the CreatedOn column value for the account record when the account edit page is opened (added to the AccountPageV2 schema from "Custom" package):
onEntityInitialized: function (){ this.callParent(arguments); this.console.log("This is the value of year of CreatedOn: "+ this.get("CreatedOn").getFullYear()); if (this.get("CreatedOn").getFullYear()===2021){ this.console.log("The record was created in 2021"); } else { this.console.log("The record was created not in 2021"); } },
And it works perfectly on my end, the getFullYear() method does what it should so you can add it to your check:
var esq = Ext.create("Terrasoft.EntitySchemaQuery", { rootSchemaName: "Opportunity" }); esq.filters.add("PC", Terrasoft.createColumnFilterWithParameter( Terrasoft.ComparisonType.EQUAL,this.get("CreatedOn").getFullYear(),this.get("Year"))
In case "Year" is an actual column on the Opportunity edit page in our case.
Best regards,
Oscar
Hello Oscar,
Thank You for feedback which drove me to the solution.
One remark:
new filters has to be added like this
esq.filters.add("yearfrom", Terrasoft.createColumnFilterWithParameter( Terrasoft.ComparisonType.GREATER_OR_EQUAL, "CreatedOn", new Date(Date.UTC("2020",0)))); esq.filters.add("yearto", Terrasoft.createColumnFilterWithParameter( Terrasoft.ComparisonType.LESS, "CreatedOn", new Date(Date.UTC("2021",0))));
because i can't add this.get() as a leftArgument in filter.
Regards,
Marcin