Disable core JavaScript method in ContractPageV2

Hi Team,

How can I disable (override) method getIncrementCode in ContractPageV2?

We dont need the Auto Numbering feature in the Contract section.

Sasori

Like 0

Like

7 comments

Hi Community,

Any update regarding the topic?

Sasor

Hi Sasori,

 

we have done the following trick in onEntityInitialized

 

onEntityInitialized: function() {
 if ((this.isAddMode() && this.Ext.isEmpty(this.get("Number"))) || this.isCopyMode()) {
  this.set("Number", ".");
 }
 this.callParent(arguments);
 if (this.get("Number")===".") {
  this.set("Number", "");
 }
},

 

Hello Vladimir,

Thank you very much for the provided code!

I have tried this snippet and it doesnt work.

When I try to save the record ( the incremented value is still stored) even though in the page there is a black space.

Sasori

Hello,

Only overriding onEntityInitialized won`t be enough because there is also a server logic that sets the Number (ContractEntityEventListener schema). If you change only the onEntityInitialized, the system will still set a number if the contract was created using BP or integration.

If you want to turn it off you will need to also override ContractEntityEventListener:

 namespace Terrasoft.Configuration
{
	using Terrasoft.Core.Entities;
	using Terrasoft.Core.Entities.Events;
	using Terrasoft.Core.Process.Configuration;
 
	[EntityEventListener(SchemaName = "Contract")]
	public class UsrContractNewEntityEventListener : BaseEntityEventListener {
 
		#region Methods: Public
 
		public override void OnInserting(object sender, EntityBeforeEventArgs e) {
			base.OnInserting(sender, e);
			var entity = (Entity)sender;
			entity.SetColumnValue("Number", "");
		}
 
		#endregion
 
	}
}

 

Dmytro,

Thank you for the excellent response!

The last problem I am facing regarding this issue is when I 'Save' the record.

The 'Number' field is a mandatory field. Even though I put a value in Number i keep getting this pop-up:

Should I do any other modifications in the code ?

Sasor

Sasori Oshigaki,

 

It's not related to any customization described either by Vladimir and Dmytro (I've tested both codes and they don't result in this ""Number" field is required" message). You have some another customization that makes the "Number" field mandatory (custom code, business rule, column settings on the object side or on the page side), you need to find and disable it.

Hi Oscar,

The number field is a required field (this is how daily business needs it)

Problem is, that even when we enter the number and save the record, the message pops-up. (Number field is required)

Is this probably because the code in the server side should be like this :

 

namespace Terrasoft.Configuration
{
	using Terrasoft.Core.Entities;
	using Terrasoft.Core.Entities.Events;
	using Terrasoft.Core.Process.Configuration;
 
	[EntityEventListener(SchemaName = "Contract")]
	public class UsrContractNewEntityEventListener : BaseEntityEventListener {
 
		#region Methods: Public
 
		public override void OnInserting(object sender, EntityBeforeEventArgs e) {
		}
 
		#endregion
 
	}
}

Just overriding the method and practicaly not do anything there ?

Sasori

Show all comments