Question

How to check open task for a particular opportunity

Hello All,

I have requirement where If I would like to change the opportunity stage the system should allow me to change stage only in following conditions:

1] If that opportunity has no opened task in action panel. If there is opened task in Opportunity edit page action panel and user tried to change the stage system should show me error message.

   I have created the task on opportunity as the stage changes but i am not able to get how to check for the open task on particular opportunity stage before going to next stage. Please provide the help. 

File attachments

Like

1 comments

Dear Amol,

In order to implement such logic, please, create a replacing client module for the opportunity page. 

Afterwards, in the method section you need to add logic. Firstly, every time you go from one stage to another the page gets reloaded. Threrfore, we need to interfere to the save method and check, if the needed field is filled in. If not, then do not save. In the example below we are checking if Email field is filled in. Please use it as an example for your opportunity page business task.

define("LeadPageV2", ["LeadPageResources"], function(resources) {
	return {
		entitySchemaName: "Lead",
		attributes: {
			"OldStatus": {
				type: Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN,
				dataValueType: Terrasoft.DataValueType.CUSTOM_OBJECT,
				value: ""
			},
			"CustomerAgree": {
				type: Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN,
				dataValueType: Terrasoft.DataValueType.BOOLEAN,
				value: false
			}
		},
		diff: /**SCHEMA_DIFF*/[]/**SCHEMA_DIFF*/,
		methods: {
			onEntityInitialized: function() {
				this.callParent(arguments);
				this.set("OldStatus", this.get("QualifyStatus"));
			},
			save: function() {
				if (this.get("OldStatus").value !== this.get("QualifyStatus").value) {
					if (this.get("Email")) {
						if (this.get("CustomerAgree") === true) {
							this.callParent(arguments);
							this.set("OldStatus", this.get("QualifyStatus"));
						} else {
							var scope = this;
							this.showConfirmationDialog("Are you sure?",
							function(returnCode) {
								if (returnCode === Terrasoft.MessageBoxButtons.YES.returnCode) {
									scope.set("CustomerAgree", true);
									scope.save();
								} else {
									this.set("QualifyStatus", this.get("OldStatus"));
								}
							}, ["yes", "no"]);
						}
					} else {
						this.showInformationDialog("Please insert the Email");
						this.set("QualifyStatus", this.get("OldStatus"));
						return false;
					}
				} else {
					this.callParent(arguments);
				}
			},
			onSaved: function() {
				this.callParent(arguments);
				this.set("CustomerAgree", false);
			}
		},
		rules: {}
	};
});

 

Show all comments