Question

Plus sign to add product in opportunity

Hello All,

Does any have an idea on how to hide + sign to add new product in opportunity based on opportunity stage. Any suggestion will be highly appreciated.

 

Thanks

File attachments
Like 2

Like

2 comments

Dear Adebola,

You can implement such task by coding. Please find the instruction to follow:

- In order not to add new records we need to disable the "+" add button. Open or create a replacing module for the detail schema. Create a boolean attribute e.g.

                "diableButton": {

                    dataValueType: this.Terrasoft.DataValueType.BOOLEAN,

                    type: this.Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN

                },

- Override the getAddRecordButtonEnabled method. Instead of basic "return true" write an" if" clause, which will be checking the attribute. If attribute is true - button will be enabled.

- Write an ESQ function to the Opportunity object to check the stage. In the callback of an ESQ set the attribute mentioned above to true or false based on the received result. See more on creating ESQ in our article:

https://academy.bpmonline.com/documents/technic-sdk/7-8/use-entityschem…

In order to obtain record Id from the detail use this.get("MasterRecordId").

- Add the call of ESQ function to the init function of detail schema, so the attribute will be set before the page will be initialized. e.g.

  init: function() {

    this.callParent(arguments);

    this.checkButton(); //ESQ function

  }

Regards,

Anastasia

Thank you Anastasia. I will follow your suggestion to get it done. One more thing please, could you help look at the code below. 

I want user to exit the current page when they click "OK" button

 

checkOpportunityStage: function(config, showConfirmationDialog) {

// var scope = this;

var message = "";

var opportunityId =  this.get("Opportunity").value;

 

var esqAdd = Ext.create("Terrasoft.EntitySchemaQuery", {

rootSchemaName: "Opportunity"

});

esqAdd.addColumn("Stage.Id", "Stage");

var esqFilter = esqAdd.createColumnFilterWithParameter(

Terrasoft.ComparisonType.EQUAL, "Id", opportunityId);

esqAdd.filters.add("esqFilter", esqFilter);

 

// Get entire record colelction and display it in an infor window.

esqAdd.getEntityCollection(function(result) {

result.collection.each(function(item) {

var stageValue = item.get("Stage");

if(stageValue === "974f2add-0b0a-4df6-b8a2-0c5cf83b88ef"){

if ((showConfirmationDialog === null) || (typeof showConfirmationDialog === "undefined")) {

showConfirmationDialog = true;

}

if (showConfirmationDialog) {

message += "You cannot add new product when proposal is already sent. This Opportunity is closed";

this.showConfirmationDialog(message, function(returnCode) {

if (returnCode === this.Terrasoft.MessageBoxButtons.YES.returnCode) {

//this.checkOppportunityStageIsNotEqualProposalSent(config, false);

//this.callParent(arguments);

}

this.save(config, false);

}, ["ok", "cancel"]);

}

}

});

 

}, this);

}

 

 

 

Thank you and hope to hear from you soonest.

Show all comments