Question

Am I able to use esq to get detail data on a page? Ideally I want to be able to get data from the detail on the parent page, but there will be multiple rows on a detail and I would like to loop through all of them and do calculations with it. I'm not sure how I would be able to get the detail data, there's no lookup connected to it, just the object column and detail column create a relationship in the page designer. I would like to do this with client-side code thanks.

Like

1 comments

Solved using filters on esq

Log in or register to comment
Question

Hi, How am I able to return a value of a Lookup (the Name) using ESQ, JS? I have defined the Lookup as an attribute: "DevCertPublicationFrequency": { DataValueType: Terrasoft.DataValueType.LOOKUP, }, I have the following function: getLookupValue: function (DevCertPublicationFrequency, safe) { var column = this.columns[DevCertPublicationFrequency]; if (column && (column.isLookup || true)) { var columnValue = this.get(DevCertPublicationFrequency); this.set("DevCertPublicationFrequency", columnValue); } }, When the record is saved I want to check the value of the Lookup and call a function if the Lookup value selected prior to the save = 'Daily' Save: function() { this.callParent(arguments); this.getLookupValue(); var textmessage = "Verification will be performed"; //if periodical edition = daily then perform verification var DevCertPubFrequency = this.get("DevCertPublicationFrequency"); if (DevCertPubFrequency === "Daily") { Terrasoft.showInformation(textmessage); this.verification(); } },

Like

1 comments

It's pretty easy to get a value from a lookup attribute using this.get("NameOfLookupAttribute"). Please debug your js code using the article below 

https://academy.bpmonline.com/documents/technic-sdk/7-13/client-code-debugging 

Log in or register to comment
Question

Hi,

I'm currently trying to obtain the "Id" from one of the contacts in my "Contact" table but I'm getting the same error:

Terrasoft.Common.ItemNotFoundException: Value "Id" was not found.
   at Terrasoft.Core.Entities.EntityColumnValueCollection.GetByName(String name)
   at Terrasoft.Core.Entities.Entity.InternalGetColumnValue(String valueName)
   at Terrasoft.Core.Entities.Entity.GetColumnValue(String valueName)
   at Terrasoft.Core.Process.UsrProcess2MethodsWrapper.ScriptTask1Execute(ProcessExecutingContext context)
   at Terrasoft.Core.Process.ProcessScriptTask.InternalExecute(ProcessExecutingContext context)
   at Terrasoft.Core.Process.ProcessFlowElement.Execute(ProcessExecutingContext context)

 

This is the script task i'm using for it:

var result = "";
var userConnection = Get<UserConnection>("UserConnection");
    
EntitySchemaManager esqManager = userConnection.EntitySchemaManager;

var rootEntitySchema = esqManager.GetInstanceByName("Contact") as EntitySchema;

var esqResult = new EntitySchemaQuery(rootEntitySchema);

esqResult.AddColumn("Id");
esqResult.AddColumn("Name");

var entities = esqResult.GetEntityCollection(UserConnection);

result = entities[0].GetColumnValue("Id").ToString();

Set<string>("ProcessSchemaParameter1", result);

return true;

Note: If i try to get the "Name" instead i dont get any error.

Like

1 comments

Try this

var opportunityCarQuery = new EntitySchemaQuery(UserConnection.EntitySchemaManager,"OpportunityCar");
opportunityCarQuery.AddAllSchemaColumns();
 
var filter = opportunityCarQuery.CreateFilterWithParameters(FilterComparisonType.Equal, "Car", (Guid)carNodeId);
opportunityCarQuery.Filters.Add(filter);
 
var opportunityCarEntities = opportunityCarQuery.GetEntityCollection(UserConnection);
 
foreach (var opportunityCarEntity in opportunityCarEntities)
{
	var theId = opportunityCarEntity.GetTypedColumnValue&lt;Guid&gt;("Id");
}

 

Log in or register to comment
Question

How can I pass a callback function to GetEntityCollection function of ESQ? 

Like

1 comments

Please debug the function in the developers console in google chrome. Once you find how it works, you'll be able to find how to pass the parameter. Additionally, you can search for the examples with the global search trough all sources in the google developers console.

Log in or register to comment
Question

Can I know how I can create insert queries and execute those using esq on the detail? 

Like

7 comments

You can use the InsertQuery client-side. Here is a sample: 

var insert = Ext.create("Terrasoft.InsertQuery", {
	rootSchemaName: "UsrMyEntity"
});
 
insert.setParameterValue("UsrMyParentId", this.get("Id"), Terrasoft.DataValueType.GUID);
insert.setParameterValue("UsrMyDateProperty", new Date(), Terrasoft.DataValueType.DATE);
 
insert.execute(function() {
	// do any refreshing if needed here
}, this);

Ryan

Ryan Farley,

Great! this helps. Is there a way I can do bulk insertion of multiple records at 1 single time? Any documentation reference would be really helpful. 

Thank you

 

kumar,

To do any sort of insertions of multiple records, I would create a configuration service and call that instead from the client. It would be far more efficient that way.

Ryan

Ryan Farley,

Hi guys, that is helping me in another implementation. Is it also possible to use it as updateQuery?

Thanks.

Danilo Lage,

Yes, an UpateQuery is similar, see the following sample:

var update = Ext.create("Terrasoft.UpdateQuery", {
	rootSchemaName: "Contact"
});
 
update.filters.add("IdFilter", update.createColumnFilterWithParameter(
	Terrasoft.ComparisonType.EQUAL, "Contact", this.get("UsrContactId")));
 
update.setParameterValue("UsrSomeField", "value", Terrasoft.DataValueType.TEXT);
update.setParameterValue("UsrSomeId", someId, Terrasoft.DataValueType.GUID);
 
update.execute(function() {
	// do any needed refreshing here etc
}, this);

Ryan

Danilo Lage,

kumar,

Please see the following articles, there you can find instructions on building update, insert, delete and batch queries. 

https://academy.bpmonline.com/documents/technic-sdk/7-13/dataservice-ad…

https://academy.bpmonline.com/documents/technic-sdk/7-13/dataservice-up…

https://academy.bpmonline.com/documents/technic-sdk/7-13/dataservice-ba…

https://academy.bpmonline.com/documents/technic-sdk/7-13/creating-detai…

The examples are done using C# language in case you decide to create a web service. Also there is a JavaScript example. They are particularly the same in the syntax. There also you can find examples of cases using insert, update, delete and batch queries.

Hope you will find it helpful.

Regards,

Anastasia

Ryan Farley,

Thanks, Ryan!

 

Anastasia Botezat,

Great, Anastasia...

Log in or register to comment
Question

what I mean is how to apply the concept of angluar js 1.x directives on custom lookup in bpm, so wirte the code of custom lookup once and add it to multiple pages.

Like

2 comments

Use mixin   A good example of mixin allows add multi-currency field

Hello.

The mixin would indeed be a decent way to achieve the desired functionality.

Best regards,

Matt

Log in or register to comment
Question

I really need to solve this question , even a part of them

-Create new filter “Attention” in the Activity section grid page (near Owner and Date filters). When turned on, only overdue activities and high priority 
 today activities should be displayed. Filter should use current user time zone.
 (using code and not filter manually)

Like

2 comments

In ActivitySectionV2 do it by analogy with this example
1) Create new filter near Owner and Date filters
{
    "operation": "insert",
    "parentName": "IsActiveFiltersContainer",
    "propertyName": "items",
    "name": "IsActiveCheckbox",
    "values": {
        "bindTo": "IsActive",
        "caption": "Активные",
        "controlConfig": {
            "className": "Terrasoft.CheckBoxEdit",
            "checkedchanged": {
                "bindTo": "onIsActiveCheckboxChecked"
            }
        }
    }
}
2)
getFilters: function () {
    var sectionFilters = this.callParent(arguments);
    this.setIsActiveFilter(sectionFilters);
    //this.setCommunicationFilter(sectionFilters);
    return sectionFilters;
},
setIsActiveFilter: function (filterCollection) {
    var isActive = this.get("IsActive");
    if (isActive) {
        if (!filterCollection.contains("IsActiveFilter")) {
            filterCollection.add("IsActiveFilter", this.Terrasoft.createColumnIsNullFilter("Account"));
        }
    } else {
        filterCollection.removeByKey("IsActiveFilter");
    }
},  
onIsActiveCheckboxChecked: function (value) {
                if (!this.get("IsSectionVisible")) {
                    return;
                }
                this.set("IsActive", value);
                this.sandbox.publish("FiltersChanged", null, [this.sandbox.id]);
                this.reloadGridData();
            },       

3)Add atribute "IsActive"

attributes: {
      "IsActive": {
          "dataValueType": this.Terrasoft.DataValueType.BOOLEAN,
          "type": this.Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN,
           "value": true
            },
        }
}

Hello!

Please see a comment from Grigoriy above, this would help you implement your idea.

Matt

Log in or register to comment
Question

Question :

On the Product edit page, develop a new button or action for calculating product popularity. Popularity is calculated as the ratio of the number 
 of products in invoice records that contain the current product, to the total number of products in invoice records. Display the calculation result 
 as a percentage using the message window.

how to solve it by esq?

Like

1 comments

Dear Mohamad,

Please see the ESQ example below. The method can be triggered by the button click on th product page.

checkProductNumber: function() {
				var currentProduct = this.get("Id");
				var esq = Ext.create("Terrasoft.EntitySchemaQuery", { rootSchemaName: "InvoiceProduct" });
				esq.addColumn("Product");
				esq.filters.add("Product", Terrasoft.createColumnFilterWithParameter(
					Terrasoft.ComparisonType.EQUAL, "Product", currentProduct));
				esq.getEntityCollection(function(response) {
					if (response &amp;&amp; response.success) {
						var quantity = response.collection.collection.length;
						if (quantity &gt; 0) {
							var esq1 = Ext.create("Terrasoft.EntitySchemaQuery", { rootSchemaName: "InvoiceProduct" });
							esq1.addColumn("Id");
							esq1.getEntityCollection(function(result) {
								if (result &amp;&amp; result.success) {
									var total = result.collection.collection.length;
									this.showInformationDialog(quantity / total);
								}
							}, this);
						} else {
							this.showInformationDialog("This product is not indicated in any invoice.");
						}
					}
				}, this);
			}

Hope you will find it helpful.

Regards, 

Anastasia

Log in or register to comment
Question

 Please help with this question :

Configure settings so that a user cannot save an invoice if the total amount of a customer's debt (taking into account the amount of the current invoice) exceeds $4,000.

 

what this mean and how to solve it?

Like

1 comments

Hello, what you described is an object logic (validation) than can be both created and deleted with code only by a skilled developer.

In many cases our customers implement similar logic purposefully.

If you need our help in resolving this case, please, let us know. 

Log in or register to comment
Question

Hi everyone,

I have query:

SELECT (
	SELECT
		count(DISTINCT(c.id))
	-- c.id, c.name
	FROM flight_detail fd
		JOIN contact c
			ON c.id = fd.contact_id
		WHERE
			-- get last year 
			(fd.departure_date &gt;= '2016-09-01' AND fd.departure_date &lt;= '2017-09-30')	
			AND
			-- get this year
			fd.contact_id IN (
				SELECT fd_ly.contact_id
				FROM flight_detail fd_ly
				WHERE 
					fd_ly.departure_date &gt;= '2017-09-01' AND fd_ly.departure_date &lt;= '2018-09-30'
			)
) AS 'Customer Last Year Who Still Buy Ticket This Year',
(
	SELECT
		count(DISTINCT(c.id))
		-- c.id, c.name
	FROM flight_detail fd
		JOIN contact c
			ON c.id = fd.contact_id
		WHERE
			-- get last year 
			(fd.departure_date &gt;= '2016-09-01' AND fd.departure_date &lt;= '2017-09-30')
) AS 'Customer Last Year';

How to transform query to JSON format for sending data paramater DataService.

This query for get data from bpm and I want show the result to my 3rd app.

Thanks.

Like

1 comments

Dear Romadan,

Not all queries can be easily translated in a single DataService request. In the most complex cases consider refactoring a query into few smaller queries and sending them one by one storing the result from first query and passing it as a parameter to the next query. 

Log in or register to comment