Question

Adding detail with lookup

Hi everyone!

I'm new with bpm online and need put a Tab Products on the new entity (UsrPedido). I attach my code. Can help me to find the mistake??

File attachments

Like

3 comments

What exception do you see in the console of the browser?

Hi Eugene. 

Thanks for the quick answare. Is my first job in bpm online and take the example from the manual.

I see this exception "The Id column is not declared in the ViewModel of the menu item"

on the all-combined.js

this.initialConfig=a||{};Ext.apply(this,b);this.callParent(arguments);this.instanceId=Terrasoft.generateGUID();this.mixins.observable.constructor.call(this);this.addEvents("destroyed")},log:function(a,b){var c=this.console;if(c){var d;switch(b){case Terrasoft.LogMessageType.INFORMATION:d=c.info;break;case Terrasoft.LogMessageType.WARNING:d=c.warn;break;case Terrasoft.LogMessageType.ERROR:d=c.error;break;default:d=c.log}d.call?d.call(c,a):d(a)}},error:function(a){this.log(a,Terrasoft.LogMessageType.ERROR)},

I recommend you to create a lookup detail in 2 steps:

1. Create an edit page detail with "detail wizard". 

https://academy.bpmonline.com/documents/sales-commerce/7-9/detail-wizard

2. Convert the edit page detail into the lookup detail.

Once you create the edit page detail and make sure that it works, please check the code below. This is how I modified an edit page detail to a lookup detail recently.

define("UsrSchema6Detail", ["ConfigurationEnums"],
function(configurationEnums) {
	return {
		entitySchemaName: "UsrAccLangInAcc",
		details: /**SCHEMA_DETAILS*/{}/**SCHEMA_DETAILS*/,
		methods: {
			openLanguageLookup: function() {
				var config = {
					entitySchemaName: "UsrAccountLanguages",
					multiSelect: true,
					columns: ["Name"]
				};
				var accountId = this.get("MasterRecordId");
				if (this.Ext.isEmpty(accountId)) {
					return;
				}
				var esq = this.Ext.create("Terrasoft.EntitySchemaQuery", {
					rootSchemaName: this.entitySchemaName
				});
				esq.addColumn("Id");
				esq.addColumn("UsrAccountLanguages.Id", "UsrAccountLanguagesId");
				esq.filters.add("filterAccount", this.Terrasoft.createColumnFilterWithParameter(
				this.Terrasoft.ComparisonType.EQUAL, "UsrAccount", accountId));
				esq.getEntityCollection(function(result) {
					var existsLanguagesCollection = [];
					if (result.success) {
						result.collection.each(function(item) {
							existsLanguagesCollection.push(item.get("UsrAccountLanguagesId"));
						});
					}
					if (existsLanguagesCollection.length > 0) {
						var existsFilter = this.Terrasoft.createColumnInFilterWithParameters("Id",
						existsLanguagesCollection);
						existsFilter.comparisonType = this.Terrasoft.ComparisonType.NOT_EQUAL;
						existsFilter.Name = "existsFilter";
						config.filters = existsFilter;
					}
					this.openLookup(config, this.addCallBack, this);
				}, this);
			},
			onCardSaved: function() {
				this.openLanguageLookup();
			},
			addCallBack: function(args) {
				var bq = this.Ext.create("Terrasoft.BatchQuery");
				var accountId = this.get("MasterRecordId");
				this.selectedRows = args.selectedRows.getItems();
				this.selectedItems = [];
				this.selectedRows.forEach(function(item) {
					item.AccountId = accountId;
					item.LanguageId = item.value;
					bq.add(this.getLanguageInsertQuery(item));
					this.selectedItems.push(item.value);
				}, this);
				if (bq.queries.length) {
					this.showBodyMask.call(this);
					bq.execute(this.onLanguageInsert, this);
				}
			},
			onLanguageInsert: function(response) {
				this.hideBodyMask.call(this);
				this.reloadGridData();
			},
			getLanguageInsertQuery: function(item) {
				var insert = Ext.create("Terrasoft.InsertQuery", {
					rootSchemaName: this.entitySchemaName
				});
				insert.setParameterValue("UsrAccount", item.AccountId, this.Terrasoft.DataValueType.GUID);
				insert.setParameterValue("UsrAccountLanguages", item.LanguageId, this.Terrasoft.DataValueType.GUID);
				return insert;
			},
			addRecord: function() {
				var masterCardState = this.sandbox.publish("GetCardState", null, [this.sandbox.id]);
				var isNewRecord = (masterCardState.state === configurationEnums.CardStateV2.ADD ||
				masterCardState.state === configurationEnums.CardStateV2.COPY);
				if (isNewRecord === true) {
					var args = {
						isSilent: true,
						messageTags: [this.sandbox.id]
					};
					this.sandbox.publish("SaveRecord", args, [this.sandbox.id]);
					return;
				}
				this.openLanguageLookup();
			},
			deleteRecords: function() {
				var selectedRows = this.getSelectedItems();
				if (selectedRows.length > 0) {
					this.set("SelectedRows", selectedRows);
					this.callParent(arguments);
				}
			},
			getCopyRecordMenuItem: Terrasoft.emptyFn,
			getEditRecordMenuItem: Terrasoft.emptyFn,
			getFilterDefaultColumnName: function() {
				return "UsrAccountLanguages";
			}
		},
		diff: /**SCHEMA_DIFF*/[]/**SCHEMA_DIFF*/
	};
});

 

Show all comments