Hi,
I have a scenario, where a custom section's record can be created from opportunity via business process, as well as from its own section page. I am trying to implement auto numbering for the section.
The problem I face is that I could not sync the sequence number from both the business process and the auto numbering, done via system settings, as the system settings value gets incremented by 1 irrespective of what the previous sequence might be.
So, I planned on using ESQ to fetch the collection of records in db, sorting them in descending order and getting the first record from it. Below is the code I have used for that.
recordIdAutoNumbering : function(callback, scope) {
var result = {
success: true
};
if (this.isAddMode() || this.isCopyMode()) {
var esq = Ext.create("Terrasoft.EntitySchemaQuery", {
rootSchemaName: "UsrClientSection"
});
var name = esq.addColumn("UsrName");
esq.orderPosition = 0;
esq.orderDirection = Terrasoft.OrderDirection.DESC;
esq.getEntityCollection(function (result) {
if (result.success) {
if (result.collection.getCount() > 0) {
// window.alert();
//result.success = false;
result.collection[0].getColumnValue(name.Name).ToString();
}
} else {
return;
}
callback.call(scope || this, result);
}, scope);
}
this.set("UsrName", result);
}
}
I am getting undefined error while fetching the "result.collection[0]". Could you please shed some light on how this scenario can be handled.
Also please suggest any better practice to get this issue solved henceforth.
Thanks,
Mohamed.
Like
You can achieve this from server side auto numbering!!! ESQ is not required if u follow it.https://academy.bpmonline.com/documents/technic-sdk/7-13/how-add-auto-numbering-edit-page-field
Or else Create a table for example.UsrAutonumber Add a integer column to it. say 1 to integer column.
take the number from this table when you are adding a record for the autonumber from ESQ . Update the column to 2 in UsrAutonumber table once you save the record .
Use server side implementation.
Thank you