Hi Everyone! 

I have a use case where I need to make adding a record to a detail on the Opportunity page mandatory for a specific stage in Opportunity DCM. 

Would anyone know how to implement it? 
Are there any differences between Classic and FUI? 
Can it be done through Validation? 

Any suggestions welcome!

Thanks so much for your help!
Jacek

Like 0

Like

4 comments
Best reply

Hello Jacek,

In order to implement your logic you will have to create the user task for adding a record to the detail and set it as required step in DCM.

Opportunity management 

Hello Jacek,

In order to implement your logic you will have to create the user task for adding a record to the detail and set it as required step in DCM.

Opportunity management 

Yeah, this is something a missing for which it's quite useful to have to behave like a mandatory field, rather than a task to fill in. 

Have not found a way other than to add task, but we did it in a business process so that it will first check if detail has some records or not. 

Use cases : Address filled in ; Products added to opp.. there's probably more. 

Our sales team are not big fans of extra tasks to validate in addition to the data to fill in.

Unfortunately, it is not possible to make some detail mandatory for filling in with user.  We registered this request and forwarded to our R&D team for consideration and implementation in future application releases.

It is possible to do with development though. 

Here is a sample algorithm for how it may be done in Classic UI. Please not that the methods in the examples serve only for giving an idea of how this may be done and don't perform actual business task: 

1) Create an ESQ to check if the detail has records added.

Example: 

checkDetailRecords: function() {
	var accountId = this.get("Id");
	var select = this.Ext.create("Terrasoft.EntitySchemaQuery", {
		rootSchemaName: "AccountAddress" //name of the detail object schema
	});
	var esqFilter = select.createColumnFilterWithParameter(Terrasoft.ComparisonType.EQUAL, "Account", accountId);
	select.getEntityCollection(function(response) {
		if (response.success) {
			var collection = result.collection;
			if (collection && collection.collection.length > 0) {
				this.set("DetailHasRecords", true);
				this.set("ESQCompleted", true);
				this.save();
			} else {
				this.set("DetailHasRecords", false);
				this.set("ESQCompleted", true);
				this.save();
			}
		}
	}, this);
}

2) After checking if there are any records you would need to save the result, for example, to an attribute: 

Example: 

attributes: {
	"DetailHasRecords": {
		"type": Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN,
		"dataValueType": Terrasoft.DataValueType.BOOLEAN,
		"value": false
	},
	"ESQCompleted": {
		"type": Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN,
		"dataValueType": Terrasoft.DataValueType.BOOLEAN,
		"value": false
	},
}

3) After that you can override save method for the opportunity to check if the detail is filled in when the opportunity in a specific stage  

Example: 

save: function() {
	if("ESQCompleted") {
		if("DetailHasRecords") {
			this.callParent();
		} else {
			this.showInformationDialog("Please fill in ....");
		}
	} else {
		this.checkDetailRecords();
	}
}

 

Also to prevent the opportunity when record was deleted from the detail and no records in the detail left you can use the method onDetailChanged: 

onDetailChanged: function(detail) {
	this.callParent(arguments);
	if (detail.schemaName === "AccountAddress")//name of the detail
		this.checkDetailRecords();
	}
}

Thank you Iryna and Damien for your replies and advice. This is much appreciated! 

Show all comments